Jan Luehe wrote:
> glassfish_at_javadesktop.org wrote:
>> I have a problem trying to configure a custom valve on glassfish v3.
>>
>> I've coded the class (attached) and generated the jar file (attached).
>>
>> I put the jar file inside the lib directory (where I put for example
>> jdbc drivers). That's /cc/glassfishv3/glassfish/lib.
>>
>> I've configured the 'server' virtual server to use the valve. I've
>> done it through the admin console but here's the resulting domain.xml
>> (fragment):
>>
>> <config name="server-config">
>> <http-service>
>> <access-log />
>> <virtual-server id="server"
>> network-listeners="http-listener-2,http-listener-1">
>> <property name="valve_1"
>> value="net.sargue.glassfish.valve.StdOutAccessLogValve" />
>> </virtual-server>
>> <virtual-server id="__asadmin"
>> network-listeners="admin-listener" />
>> </http-service>
>>
>> So everything seems fine but upon starting the server this is what I
>> get on the logs.
>>
>
> The above config looks right.
> Taking a closer look at the failure ...
Thanks for reporting this issue! I've filed it as
https://glassfish.dev.java.net/issues/show_bug.cgi?id=11674
Turns out VirtualServer#loadInstance was using the wrong classloader
when attempting to load the specified custom valve class: It was using
the classloader that had loaded VirtualServer.class, which does not have
any visibility into jars in $instance/lib or classes in
$instance/lib/classes. The correct classloader to use is the
CommonClassLoader.
I'm about to commit a fix to the trunk (GlassFish v3.1), and will also
port the fix to GF v3.0.1.
I will also add a unit test to make sure that this feature will not
regress in future GlassFish releases.
Thanks,
Jan
>
> Jan
>
>> [#|2010-03-11T12:25:25.027+0100|INFO|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=Thread-1;|Created
>> HTTP listener http-listener-2 on port 8181|#]
>>
>> [#|2010-03-11T12:25:25.036+0100|INFO|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=Thread-1;|Created
>> HTTP listener admin-listener on port 4848|#]
>>
>> [#|2010-03-11T12:25:25.062+0100|SEVERE|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=FelixStartLevel;|WEB0148:
>> Unable to load extension class [{0}] from web module [{1}]
>> java.lang.ClassNotFoundException:
>> net.sargue.glassfish.valve.StdOutAccessLogValve
>> at
>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:744)
>>
>> at
>> org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:61)
>> at
>> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1656)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
>> at java.lang.Class.forName0(Native Method)
>> at java.lang.Class.forName(Class.java:169)
>> at
>> com.sun.enterprise.web.VirtualServer.loadInstance(VirtualServer.java:1063)
>>
>> at
>> com.sun.enterprise.web.VirtualServer.addValve(VirtualServer.java:1030)
>> at
>> com.sun.enterprise.web.VirtualServer.configureCatalinaProperties(VirtualServer.java:904)
>>
>> at
>> com.sun.enterprise.web.WebContainer.configureHost(WebContainer.java:1246)
>>
>> at
>> com.sun.enterprise.web.WebContainer.createHost(WebContainer.java:1177)
>> at
>> com.sun.enterprise.web.WebContainer.createHosts(WebContainer.java:1116)
>> at
>> com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:558)
>> at
>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
>> at
>> com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
>> at
>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>
>> at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>> at
>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>
>> at
>> org.glassfish.internal.data.EngineInfo.getContainer(EngineInfo.java:78)
>> at
>> com.sun.enterprise.v3.services.impl.WebContainerStarter.startWebContainer(WebContainerStarter.java:202)
>>
>> at
>> com.sun.enterprise.v3.services.impl.WebContainerStarter.postConstruct(WebContainerStarter.java:144)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
>> at
>> com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
>> at
>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>
>> at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>> at
>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>
>> at
>> com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
>>
>> at
>> com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
>>
>> at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
>> at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
>> at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
>> at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
>>
>> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
>> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
>> at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
>> at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
>>
>> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
>> at
>> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
>> at
>> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>> at java.lang.Thread.run(Thread.java:619)
>> |#]
>>
>> [#|2010-03-11T12:25:25.062+0100|SEVERE|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=Thread-1;|WEB0148:
>> Unable to load extension class [{0}] from web module [{1}]
>> java.lang.ClassNotFoundException:
>> net.sargue.glassfish.valve.StdOutAccessLogValve
>> at
>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:744)
>>
>> at
>> org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:61)
>> at
>> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1656)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
>> at java.lang.Class.forName0(Native Method)
>> at java.lang.Class.forName(Class.java:169)
>> at
>> com.sun.enterprise.web.VirtualServer.loadInstance(VirtualServer.java:1063)
>>
>> at
>> com.sun.enterprise.web.VirtualServer.addValve(VirtualServer.java:1030)
>> at
>> com.sun.enterprise.web.VirtualServer.configureCatalinaProperties(VirtualServer.java:904)
>>
>> at
>> com.sun.enterprise.web.WebContainer.configureHost(WebContainer.java:1246)
>>
>> at
>> com.sun.enterprise.web.WebContainer.createHost(WebContainer.java:1177)
>> at
>> com.sun.enterprise.web.WebContainer.createHosts(WebContainer.java:1116)
>> at
>> com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:558)
>> at
>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
>> at
>> com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
>> at
>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>
>> at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>> at
>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>
>> at
>> org.glassfish.internal.data.EngineInfo.getContainer(EngineInfo.java:78)
>> at
>> com.sun.enterprise.v3.services.impl.WebContainerStarter.startWebContainer(WebContainerStarter.java:202)
>>
>> at
>> com.sun.enterprise.v3.services.impl.WebContainerStarter.postConstruct(WebContainerStarter.java:144)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
>> at
>> com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
>>
>> at
>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
>> at
>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>
>> at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>> at
>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>
>> at
>> com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
>>
>> at
>> com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
>>
>> at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
>> at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
>> at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
>> at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
>>
>> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
>> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
>> at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
>> at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
>>
>> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
>> at
>> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
>> at
>> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>> at java.lang.Thread.run(Thread.java:619)
>> |#]
>>
>> [#|2010-03-11T12:25:25.064+0100|WARNING|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=FelixStartLevel;|WEB0158:
>> Object of type classname
>> [net.sargue.glassfish.valve.StdOutAccessLogValve] not an instance of
>> Valve or GlassFishValve|#]
>>
>> [#|2010-03-11T12:25:25.064+0100|WARNING|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=Thread-1;|WEB0158:
>> Object of type classname
>> [net.sargue.glassfish.valve.StdOutAccessLogValve] not an instance of
>> Valve or GlassFishValve|#]
>>
>> [#|2010-03-11T12:25:25.142+0100|INFO|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=Thread-1;|Created
>> virtual server server|#]
>>
>> |#]
>>
>> [#|2010-03-11T12:25:25.144+0100|INFO|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=FelixStartLevel;|Created
>> virtual server __asadmin|#]
>>
>>
>>
>>
>> Strange mix of messages! Not found but also not the correct type.
>> Perhaps the second is a follow-up from the first one.
>>
>> Any idea on what I'm doing wrong?
>> [Message sent by forum member 'sargue' (sargue_at_gmail.com)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=391204
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>
>