[GLASSFISH-11674] Configuring virtual-server with custom valve results in CNFE Created: 11/Mar/10  Updated: 11/Jul/13  Resolved: 13/Jun/11

Status: Closed
Project: glassfish
Component/s: web_container
Affects Version/s: V3
Fix Version/s: 3.1

Type: Bug Priority: Major
Reporter: jluehe Assignee: Shing Wai Chan
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: Macintosh


Issuezilla Id: 11,674

 Description   

See http://forums.java.net/jive/thread.jspa?messageID=391204:

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.

[#|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.



 Comments   
Comment by jluehe [ 11/Mar/10 ]

Fixed by using CommonClassLoader to load custom valve class:

Sending v3/web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java
Sending v3/web/web-glue/src/main/java/com/sun/enterprise/web/WebContainer.java
Transmitting file data ..
Committed revision 35963.

Comment by jluehe [ 13/Mar/10 ]

Incremental fix: Make sure StandardPipeline#hasNonBasicValves also considers the
presence of Tomcat-style valves

Sending v3/web/web-core/src/main/java/org/apache/catalina/core/StandardPipeline.java
Transmitting file data .
Committed revision 35981.

Added unit test at
https://svn.dev.java.net/svn/glassfish-svn/trunk/v2/appserv-tests/devtests/web/virtualServerWithCustomValves

Comment by jluehe [ 13/Mar/10 ]

Ported fix to v3.0.1:

Sending
web/web-core/src/main/java/org/apache/catalina/core/StandardPipeline.java
Sending web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java
Sending web/web-glue/src/main/java/com/sun/enterprise/web/WebContainer.java
Transmitting file data ...
Committed revision 35982.

Comment by gernot1 [ 30/Apr/11 ]

I'm using Glassfish 3.1 - and it doesn't work - I still get a CNFE!
Is the fix included in v3.1?

Comment by akind [ 07/Jun/11 ]

This bug should be reopened!

I'm using GF3.1 and I'm getting the same CNFE when I configure an errorReportValve:

PWC1344: Couldn't load specified error report valve class: custom.ErrorValve
java.lang.ClassNotFoundException: custom.ErrorValve not found by org.glassfish.web.core [163]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
...

Comment by Amy Roh [ 10/Jun/11 ]

Custom vales for virtual server are working as expected. Try putting the jar in glassfish/domains/domain/lib.

See our unit test virtualServerWithCustomValves [1] for example.

[1] http://java.net/projects/glassfish/sources/svn/show/trunk/v2/appserv-tests/devtests/web/virtualServerWithCustomValves

Comment by Sanjeeb Sahoo [ 10/Jun/11 ]

Based on user request, I have reopened the bug. See http://forums.java.net/node/796752

Comment by Shing Wai Chan [ 13/Jun/11 ]

We have verified that the issue has been fixed. As mentioned by Amy, there is already a test in appserv-tests/devtests/web/virtualServerWithCustomValves, where the valves libraries jar is copied into domains/domain1/lib.

Please check that the libraries is packed correctly.

Comment by gernot1 [ 16/Jun/11 ]

You say that you cannot reproduce the bug, so I hope you can say what I'm doing wrong, because it does not work for me.

I wrote following demo valve:

package demo;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;

public class Valve1 extends ValveBase {
@Override
public void invoke(Request arg0, Response arg1) throws IOException,
ServletException

{ System.out.println("VALVE ************************"); }

}

I made a jar which contains the above class and put it in "glassfish/domains/domain1/lib"

I put a context.xml in <WebRoot>/META-INF with following content
<Context>
<Valve className="demo.Valve1" />
</Context>

started glassfish and got following error:
SCHWERWIEGEND: Begin event threw exception
java.lang.ClassNotFoundException: demo.Valve1 not found by org.glassfish.web.glue [248]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:246)
at org.apache.tomcat.util.digester.Rule.begin(Rule.java:192)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1386)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1671)
at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:828)
at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:769)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1028)
at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:176)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:6477)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5089)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)

SCHWERWIEGEND: PWC3026: Parse error in default web.xml
java.lang.ClassNotFoundException: demo.Valve1 not found by org.glassfish.web.glue [248]
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2812)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2838)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1389)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1671)
at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:828)
at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:769)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1028)
at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:176)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:6477)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5089)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: demo.Valve1 not found by org.glassfish.web.glue [248]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:246)
at org.apache.tomcat.util.digester.Rule.begin(Rule.java:192)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1386)
... 57 more

So whats wrong??

I tested the valve (with the same identical jar) in a standalone tomcat 5.5 and there it works perfectly!!

I my eyes this is a bug in Glassfish 3.1, because in a standalone tomcat it works correctly - therefore please fix the bug

Comment by akind [ 24/Jun/11 ]

Yes Amy you are right, your unittest is working fine for "normal" custom valves (valve_1, valve_2, ...) but not for an "errorReportValve".

So, may someone take a look at that?

Comment by Amy Roh [ 24/Jun/11 ]

gernot1,

Can you try the following instead of using context.xml?

asadmin set server.http-service.virtual-server.server.property.valve_1=demo.Valve1
asadmin restart-domain

Comment by Amy Roh [ 24/Jun/11 ]

akind,

How are you adding an ErrorReportValve? Are you referring to the org.apache.catalina.valves.ErrorReportValve that GlassFish already includes? The following context.xml seems to work for me. What errors are you getting?

<Context>
<Valve className="org.apache.catalina.valves.ErrorReportValve"/>
</Context>

Comment by akind [ 27/Jun/11 ]

I'm adding the valve with the following commands:
asadmin set server.http-service.virtual-server.server.property.errorReportValve=custom.ErrorValve
asadmin restart-domain

My custom.ErrorValve originally implemented the org.glassfish.web.valve.GlassFishValve interface, but I tried to extend the org.apache.catalina.valves.ErrorReportValve as you mentioned as well. Both implementations with the same CNFE that I posted on 07/Jun/11.

Using the context.xml within a war file is not an option for me, because I have to set the errorReportValve serverwide, not only for one specific war.

Comment by gernot1 [ 27/Jun/11 ]

amyroh,

when using
asadmin set server.http-service.virtual-server.server.property.valve_1=demo.Valve1
it works!

But I'd like to use the context.xml approach, because I'll have different valves for different wars.
Is the use of context.xml for configuring valves a "legal" approach? Should it work on Glassfish 3.1? Is there a bug, because it's not working for me?

Comment by Amy Roh [ 27/Jun/11 ]

gernot1,

In order to specify a custom valve for each web application, you can use sun-web.xml or glassfish-web.xml.

For example, the following sun-web.xml defines a TomcatValve for the web applicaiton.

<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app>
<valve name="TomcatValve" class-name="valves.TomcatValveBase_1"/>
</valve>
</sun-web-app>

Comment by Amy Roh [ 27/Jun/11 ]

akind,

Can you attach your valve and your domain.xml? ErrorReportValve shouldn't be any different from other custom valves and it should work as expected.

Comment by akind [ 28/Jun/11 ]

amy,

I' not allowed to attach files to this issue, so I put it here:

Here the Valves (one implements org.glassfish.web.valve.GlassFishValve, and one extends org.apache.catalina.valves.ErrorReportValve), both are working fine as normal valves (valve_1, valve_2), but not as errorReportValve:
package custom;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Request;
import org.apache.catalina.Response;
import org.glassfish.web.valve.GlassFishValve;
public class ErrorValve1 implements GlassFishValve {
@Override
public String getInfo()

{ return getClass().getName(); }
@Override
public int invoke(Request request, Response respinse) throws IOException, ServletException { System.out.println("invoke valve: "+ getInfo()); return INVOKE_NEXT; }
@Override
public void postInvoke(Request request, Response response) throws IOException, ServletException { HttpServletResponse httpResp = (HttpServletResponse) response.getResponse(); System.out.println("postInvoke valve: "+ getInfo()+ " - HttpStatus: "+httpResp.getStatus()); }
}

package custom;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Request;
import org.apache.catalina.Response;
import org.apache.catalina.valves.ErrorReportValve;
public class ErrorValve2 extends ErrorReportValve {
@Override
public String getInfo() { return getClass().getName(); }

@Override
public int invoke(Request request, Response respinse) throws IOException, ServletException

{ System.out.println("invoke valve: "+ getInfo()); return INVOKE_NEXT; }

@Override
public void postInvoke(Request request, Response response) throws IOException, ServletException

{ HttpServletResponse httpResp = (HttpServletResponse) response.getResponse(); System.out.println("postInvoke valve: "+ getInfo()+ " - HttpStatus: "+httpResp.getStatus()); }

}

And here is my domain.xml. It's out of the box with two modifications:
1. the valves (valve_1 and errorReportValve)
2. my deployed testApp

<domain log-root="$

{com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}

/applications" version="43">
<system-applications>
<application context-root="" location="$

{com.sun.aas.installRootURI}

/lib/install/applications/_admingui" name="_admingui" directory-deployed="true" object-type="system-admin">
<module name="__admingui">
<engine sniffer="web"></engine>
<engine sniffer="security"></engine>
</module>
</application>
</system-applications>
<applications>
<application context-root="/testApp" location="$

{com.sun.aas.instanceRootURI}/applications/testApp/" name="testApp" object-type="user">
<property name="appLocation" value="${com.sun.aas.instanceRootURI}

/applications/__internal/testApp/testApp2100515545419779738.war"></property>
<property name="defaultAppName" value="testApp2100515545419779738"></property>
<module name="testApp">
<engine sniffer="security"></engine>
<engine sniffer="web"></engine>
</module>
</application>
</applications>
<resources>
<jdbc-resource pool-name="_TimerPool" jndi-name="jdbc/_TimerPool" object-type="system-admin"></jdbc-resource>
<jdbc-resource pool-name="DerbyPool" jndi-name="jdbc/__default"></jdbc-resource>
<jdbc-connection-pool datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource" res-type="javax.sql.XADataSource" name="__TimerPool">
<property name="databaseName" value="$

{com.sun.aas.instanceRoot}/lib/databases/ejbtimer"></property>
<property name="connectionAttributes" value=";create=true"></property>
</jdbc-connection-pool>
<jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource" name="DerbyPool">
<property name="PortNumber" value="1527"></property>
<property name="Password" value="APP"></property>
<property name="User" value="APP"></property>
<property name="serverName" value="localhost"></property>
<property name="DatabaseName" value="sun-appserv-samples"></property>
<property name="connectionAttributes" value=";create=true"></property>
</jdbc-connection-pool>
</resources>
<servers>
<server name="server" config-ref="server-config">
<application-ref ref="_admingui" virtual-servers="_asadmin"></application-ref>
<application-ref ref="testApp" virtual-servers="server"></application-ref>
<resource-ref ref="jdbc/__TimerPool"></resource-ref>
<resource-ref ref="jdbc/__default"></resource-ref>
</server>
</servers>
<nodes>
<node node-host="localhost" name="localhost-domain1" type="CONFIG" install-dir="${com.sun.aas.productRoot}"></node>
</nodes>
<configs>
<config name="server-config">
<http-service>
<access-log></access-log>
<virtual-server id="server" network-listeners="http-listener-1,http-listener-2">
<property name="errorReportValve" value="custom.ErrorValve1"></property>
<property name="valve_1" value="custom.ErrorValve2"></property>
</virtual-server>
<virtual-server id="__asadmin" network-listeners="admin-listener"></virtual-server>
</http-service>
<iiop-service>
<orb use-thread-pool-ids="thread-pool-1"></orb>
<iiop-listener port="3700" id="orb-listener-1" address="0.0.0.0" lazy-init="true"></iiop-listener>
<iiop-listener port="3820" id="SSL" address="0.0.0.0" security-enabled="true">
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as"></ssl>
</iiop-listener>
<iiop-listener port="3920" id="SSL_MUTUALAUTH" address="0.0.0.0" security-enabled="true">
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as" client-auth-enabled="true"></ssl>
</iiop-listener>
</iiop-service>
<admin-service system-jmx-connector-name="system" type="das-and-server">
<jmx-connector port="8686" address="0.0.0.0" security-enabled="false" auth-realm-name="admin-realm" name="system"></jmx-connector>
<property name="adminConsoleContextRoot" value="/admin"></property>
<property name="adminConsoleDownloadLocation" value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"></property>
<property name="ipsRoot" value="${com.sun.aas.installRoot}/.."></property>
<das-config></das-config>
</admin-service>
<connector-service></connector-service>
<web-container>
<session-config>
<session-manager>
<manager-properties></manager-properties>
<store-properties></store-properties>
</session-manager>
<session-properties></session-properties>
</session-config>
</web-container>
<ejb-container session-store="${com.sun.aas.instanceRoot}

/session-store">
<ejb-timer-service></ejb-timer-service>
</ejb-container>
<mdb-container></mdb-container>
<jms-service default-jms-host="default_JMS_host" type="EMBEDDED">
<jms-host host="localhost" name="default_JMS_host"></jms-host>
</jms-service>
<security-service>
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="admin-realm">
<property name="file" value="$

{com.sun.aas.instanceRoot}/config/admin-keyfile"></property>
<property name="jaas-context" value="fileRealm"></property>
</auth-realm>
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="file">
<property name="file" value="${com.sun.aas.instanceRoot}

/config/keyfile"></property>
<property name="jaas-context" value="fileRealm"></property>
</auth-realm>
<auth-realm classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" name="certificate"></auth-realm>
<jacc-provider policy-provider="com.sun.enterprise.security.provider.PolicyWrapper" name="default" policy-configuration-factory-provider="com.sun.enterprise.security.provider.PolicyConfigurationFactoryImpl">
<property name="repository" value="$

{com.sun.aas.instanceRoot}/generated/policy"></property>
</jacc-provider>
<jacc-provider policy-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyProvider" name="simple" policy-configuration-factory-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyConfigurationFactory"></jacc-provider>
<audit-module classname="com.sun.enterprise.security.Audit" name="default">
<property name="auditOn" value="false"></property>
</audit-module>
<message-security-config auth-layer="SOAP">
<provider-config provider-type="client" provider-id="XWS_ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="dynamic.username.password" value="false"></property>
<property name="debug" value="false"></property>
</provider-config>
<provider-config provider-type="client" provider-id="ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="dynamic.username.password" value="false"></property>
<property name="debug" value="false"></property>
<property name="security.config" value="${com.sun.aas.instanceRoot}

/config/wss-server-config-1.0.xml"></property>
</provider-config>
<provider-config provider-type="server" provider-id="XWS_ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="debug" value="false"></property>
</provider-config>
<provider-config provider-type="server" provider-id="ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="debug" value="false"></property>
<property name="security.config" value="$

{com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
</provider-config>
</message-security-config>
<message-security-config auth-layer="HttpServlet">
<provider-config provider-type="server" provider-id="GFConsoleAuthModule" class-name="org.glassfish.admingui.common.security.AdminConsoleAuthModule">
<request-policy auth-source="sender"></request-policy>
<response-policy></response-policy>
<property name="restAuthURL" value="http://localhost:${ADMIN_LISTENER_PORT}/management/sessions"></property>
<property name="loginPage" value="/login.jsf"></property>
<property name="loginErrorPage" value="/loginError.jsf"></property>
</provider-config>
</message-security-config>
<property name="default-digest-algorithm" value="SHA-256"></property>
</security-service>
<transaction-service tx-log-dir="${com.sun.aas.instanceRoot}

/logs"></transaction-service>
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" system-classpath="" classpath-suffix="">
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-client</jvm-options>
<jvm-options>-Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder</jvm-options>
<jvm-options>-XX:+UnlockDiagnosticVMOptions</jvm-options>
<jvm-options>-Djava.endorsed.dirs=$

{com.sun.aas.installRoot}/modules/endorsed${path.separator}${com.sun.aas.installRoot}

/lib/endorsed</jvm-options>
<jvm-options>-Djava.security.policy=$

{com.sun.aas.instanceRoot}/config/server.policy</jvm-options>
<jvm-options>-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}

/config/login.conf</jvm-options>
<jvm-options>-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as</jvm-options>
<jvm-options>-Xmx512m</jvm-options>
<jvm-options>-Djavax.net.ssl.keyStore=$

{com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
<jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}

/config/cacerts.jks</jvm-options>
<jvm-options>-Djava.ext.dirs=$

{com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}

/jre/lib/ext$

{path.separator}${com.sun.aas.instanceRoot}/lib/ext</jvm-options>
<jvm-options>-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver</jvm-options>
<jvm-options>-DANTLR_USE_DIRECT_CLASS_LOADING=true</jvm-options>
<jvm-options>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
<jvm-options>-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command</jvm-options>
<jvm-options>-Dosgi.shell.telnet.port=6666</jvm-options>
<jvm-options>-Dosgi.shell.telnet.maxconn=1</jvm-options>
<jvm-options>-Dosgi.shell.telnet.ip=127.0.0.1</jvm-options>
<jvm-options>Dgosh.args=-nointeractive</jvm-options>
<jvm-options>-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/</jvm-options>
<jvm-options>-Dfelix.fileinstall.poll=5000</jvm-options>
<jvm-options>-Dfelix.fileinstall.log.level=2</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.new.start=true</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.startTransient=true</jvm-options>
<jvm-options>-Dfelix.fileinstall.disableConfigSave=false</jvm-options>
<jvm-options>-XX:NewRatio=2</jvm-options>
</java-config>
<network-config>
<protocols>
<protocol name="http-listener-1">
<http default-virtual-server="server" max-connections="250">
<file-cache></file-cache>
</http>
</protocol>
<protocol security-enabled="true" name="http-listener-2">
<http default-virtual-server="server" max-connections="250">
<file-cache></file-cache>
</http>
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" ssl3-enabled="false" cert-nickname="s1as"></ssl>
</protocol>
<protocol name="admin-listener">
<http default-virtual-server="__asadmin" max-connections="250" encoded-slash-enabled="true">
<file-cache></file-cache>
</http>
</protocol>
</protocols>
<network-listeners>
<network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
<network-listener port="8181" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool"></network-listener>
<network-listener port="4848" protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="admin-thread-pool"></network-listener>
</network-listeners>
<transports>
<transport name="tcp"></transport>
</transports>
</network-config>
<thread-pools>
<thread-pool name="admin-thread-pool" max-thread-pool-size="50" max-queue-size="256"></thread-pool>
<thread-pool name="http-thread-pool"></thread-pool>
<thread-pool name="thread-pool-1" max-thread-pool-size="200"></thread-pool>
</thread-pools>
<monitoring-service>
<module-monitoring-levels></module-monitoring-levels>
</monitoring-service>
<group-management-service>
<failure-detection></failure-detection>
</group-management-service>
</config>
<config name="default-config">
<http-service>
<access-log></access-log>
<virtual-server id="server" network-listeners="http-listener-1, http-listener-2">
<property name="default-web-xml" value="${com.sun.aas.instanceRoot}/config/default-web.xml"></property>
</virtual-server>
<virtual-server id="__asadmin" network-listeners="admin-listener"></virtual-server>
</http-service>
<iiop-service>
<orb use-thread-pool-ids="thread-pool-1"></orb>
<iiop-listener port="${IIOP_LISTENER_PORT}" id="orb-listener-1" address="0.0.0.0"></iiop-listener>
<iiop-listener port="${IIOP_SSL_LISTENER_PORT}" id="SSL" address="0.0.0.0" security-enabled="true">
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as"></ssl>
</iiop-listener>
<iiop-listener port="${IIOP_SSL_MUTUALAUTH_PORT}" id="SSL_MUTUALAUTH" address="0.0.0.0" security-enabled="true">
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as" client-auth-enabled="true"></ssl>
</iiop-listener>
</iiop-service>
<admin-service system-jmx-connector-name="system">
<jmx-connector port="${JMX_SYSTEM_CONNECTOR_PORT}" address="0.0.0.0" security-enabled="false" auth-realm-name="admin-realm" name="system"></jmx-connector>
<property name="adminConsoleDownloadLocation" value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"></property>
<das-config></das-config>
</admin-service>
<web-container>
<session-config>
<session-manager>
<manager-properties></manager-properties>
<store-properties></store-properties>
</session-manager>
<session-properties></session-properties>
</session-config>
</web-container>
<ejb-container session-store="${com.sun.aas.instanceRoot}/session-store">
<ejb-timer-service></ejb-timer-service>
</ejb-container>
<mdb-container></mdb-container>
<jms-service addresslist-behavior="priority" default-jms-host="default_JMS_host" type="EMBEDDED">
<jms-host port="${JMS_PROVIDER_PORT}" host="localhost" name="default_JMS_host"></jms-host>
</jms-service>
<log-service log-rotation-limit-in-bytes="2000000" file="${com.sun.aas.instanceRoot}/logs/server.log">
<module-log-levels></module-log-levels>
</log-service>
<security-service>
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="admin-realm">
<property name="file" value="${com.sun.aas.instanceRoot}/config/admin-keyfile"></property>
<property name="jaas-context" value="fileRealm"></property>
</auth-realm>
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="file">
<property name="file" value="${com.sun.aas.instanceRoot}/config/keyfile"></property>
<property name="jaas-context" value="fileRealm"></property>
</auth-realm>
<auth-realm classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" name="certificate"></auth-realm>
<jacc-provider policy-provider="com.sun.enterprise.security.provider.PolicyWrapper" name="default" policy-configuration-factory-provider="com.sun.enterprise.security.provider.PolicyConfigurationFactoryImpl">
<property name="repository" value="${com.sun.aas.instanceRoot}/generated/policy"></property>
</jacc-provider>
<jacc-provider policy-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyProvider" name="simple" policy-configuration-factory-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyConfigurationFactory"></jacc-provider>
<audit-module classname="com.sun.enterprise.security.Audit" name="default">
<property name="auditOn" value="false"></property>
</audit-module>
<message-security-config auth-layer="SOAP">
<provider-config provider-type="client" provider-id="XWS_ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="dynamic.username.password" value="false"></property>
<property name="debug" value="false"></property>
</provider-config>
<provider-config provider-type="client" provider-id="ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="dynamic.username.password" value="false"></property>
<property name="debug" value="false"></property>
<property name="security.config" value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
</provider-config>
<provider-config provider-type="server" provider-id="XWS_ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="debug" value="false"></property>
</provider-config>
<provider-config provider-type="server" provider-id="ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
<request-policy auth-source="content"></request-policy>
<response-policy auth-source="content"></response-policy>
<property name="encryption.key.alias" value="s1as"></property>
<property name="signature.key.alias" value="s1as"></property>
<property name="debug" value="false"></property>
<property name="security.config" value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
</provider-config>
</message-security-config>
</security-service>
<transaction-service tx-log-dir="${com.sun.aas.instanceRoot}/logs" automatic-recovery="true"></transaction-service>
<diagnostic-service></diagnostic-service>
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${JAVA_DEBUGGER_PORT}" system-classpath="" classpath-suffix="">
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-server</jvm-options>
<jvm-options>-XX:+UnlockDiagnosticVMOptions</jvm-options>
<jvm-options>-Djava.endorsed.dirs=${com.sun.aas.installRoot}/modules/endorsed${path.separator}

$

{com.sun.aas.installRoot}/lib/endorsed</jvm-options>
<jvm-options>-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy</jvm-options>
<jvm-options>-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf</jvm-options>
<jvm-options>-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as</jvm-options>
<jvm-options>-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
<jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks</jvm-options>
<jvm-options>-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext</jvm-options>
<jvm-options>-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver</jvm-options>
<jvm-options>-DANTLR_USE_DIRECT_CLASS_LOADING=true</jvm-options>
<jvm-options>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
<jvm-options>-XX:NewRatio=2</jvm-options>
<jvm-options>-Xmx512m</jvm-options>
<jvm-options>-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command</jvm-options>
<jvm-options>-Dosgi.shell.telnet.port=${OSGI_SHELL_TELNET_PORT}</jvm-options>
<jvm-options>-Dosgi.shell.telnet.maxconn=1</jvm-options>
<jvm-options>-Dosgi.shell.telnet.ip=127.0.0.1</jvm-options>
<jvm-options>Dgosh.args=-noshutdown -c noop=true</jvm-options>
<jvm-options>-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}

/modules/autostart/</jvm-options>
<jvm-options>-Dfelix.fileinstall.poll=5000</jvm-options>
<jvm-options>-Dfelix.fileinstall.log.level=3</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.new.start=true</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.startTransient=true</jvm-options>
<jvm-options>-Dfelix.fileinstall.disableConfigSave=false</jvm-options>
</java-config>
<availability-service>
<web-container-availability></web-container-availability>
<ejb-container-availability sfsb-store-pool-name="jdbc/hastore"></ejb-container-availability>
<jms-availability></jms-availability>
</availability-service>
<network-config>
<protocols>
<protocol name="http-listener-1">
<http default-virtual-server="server">
<file-cache></file-cache>
</http>
</protocol>
<protocol security-enabled="true" name="http-listener-2">
<http default-virtual-server="server">
<file-cache></file-cache>
</http>
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" ssl3-enabled="false" cert-nickname="s1as"></ssl>
</protocol>
<protocol name="admin-listener">
<http default-virtual-server="__asadmin" max-connections="250">
<file-cache></file-cache>
</http>
</protocol>
</protocols>
<network-listeners>
<network-listener port="$

{HTTP_LISTENER_PORT}

" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
<network-listener port="$

{HTTP_SSL_LISTENER_PORT}

" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool"></network-listener>
<network-listener port="$

{ASADMIN_LISTENER_PORT}

" protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="admin-thread-pool"></network-listener>
</network-listeners>
<transports>
<transport name="tcp"></transport>
</transports>
</network-config>
<thread-pools>
<thread-pool name="http-thread-pool"></thread-pool>
<thread-pool max-thread-pool-size="200" name="thread-pool-1"></thread-pool>
<thread-pool name="admin-thread-pool" max-thread-pool-size="50" max-queue-size="256"></thread-pool>
</thread-pools>
<group-management-service>
<failure-detection></failure-detection>
</group-management-service>
<management-rules></management-rules>
<system-property name="ASADMIN_LISTENER_PORT" value="24848"></system-property>
<system-property name="HTTP_LISTENER_PORT" value="28080"></system-property>
<system-property name="HTTP_SSL_LISTENER_PORT" value="28181"></system-property>
<system-property name="JMS_PROVIDER_PORT" value="27676"></system-property>
<system-property name="IIOP_LISTENER_PORT" value="23700"></system-property>
<system-property name="IIOP_SSL_LISTENER_PORT" value="23820"></system-property>
<system-property name="IIOP_SSL_MUTUALAUTH_PORT" value="23920"></system-property>
<system-property name="JMX_SYSTEM_CONNECTOR_PORT" value="28686"></system-property>
<system-property name="OSGI_SHELL_TELNET_PORT" value="26666"></system-property>
<system-property name="JAVA_DEBUGGER_PORT" value="29009"></system-property>
<monitoring-service>
<module-monitoring-levels></module-monitoring-levels>
</monitoring-service>
<connector-service></connector-service>
</config>
</configs>
<property name="administrative.domain.name" value="domain1"></property>
<load-balancers></load-balancers>
<lb-configs></lb-configs>
<clusters></clusters>
</domain>

And finally here is the code of my testServlet:
@WebServlet(urlPatterns=

{"/valveServlet"}

)
public class ValveServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if(req.getParameter("error")==null)

{ resp.getWriter().write("No Error"); }

else

{ resp.getWriter().write("Error"); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); }

}
}

Comment by meikw [ 22/Jul/11 ]

What is the status on this? It's been almost a month since the last comment. Is there a fix? I'm having the same problem as akind.

Comment by Shing Wai Chan [ 23/Jul/11 ]

I find out the problem. The normal custom valve is working.
It is a different issue from the original issue here.
The problem occurs for error report valve only.

The errorReportValve has a different configuration setting as you also mentioned.
I have filed a different issue to track custom errorReportValve issue:
http://java.net/jira/browse/GLASSFISH-17093

Comment by szhb69 [ 11/Jul/13 ]

to whom it concerns.
As Oracle decided to declare jdk 6 as legacy, I downloaded jdk-7u25-windows-x64 and declared it as default, starting eclipse kepler with it, and assigning jdk1.7.0_25 as JRE System library for all modules. Next I startet the application within eclipse on glassfish 3.1.2. This provoked the following log entry:
SEVERE: PWC1344: Couldn't load specified error report valve class: org.apache.catalina.valves.ErrorReportValvejava.lang.NullPointerException at com.sun.enterprise.web.VirtualServer.loadInstance(VirtualServer.java:1253) at org.apache.catalina.core.StandardHost.configureStandardHostValve(StandardHost.java:1370) at org.apache.catalina.core.StandardHost.setPipeline(StandardHost.java:258) at com.sun.enterprise.web.VirtualServer.configureRedirect(VirtualServer.java:1461) at com.sun.enterprise.web.WebContainer.createHost(WebContainer.java:1366) at com.sun.enterprise.web.WebContainer.createHost(WebContainer.java:1190) at com.sun.enterprise.web.WebContainer.createHosts(WebContainer.java:1157) at com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:579) at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131) at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91) at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82) at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67) at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139) at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78) at org.glassfish.internal.data.EngineInfo.getContainer(EngineInfo.java:93) at com.sun.enterprise.v3.services.impl.WebContainerStarter.startWebContainer(WebContainerStarter.java:202) at com.sun.enterprise.v3.services.impl.WebContainerStarter.postConstruct(WebContainerStarter.java:134) at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131) at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91) at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82) at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67) at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139) at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78) at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253) at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145) at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136) at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79) at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63) at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69) at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97) at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
I'll not further investigate on it, I just go back to jdk 1.6. Nevertheless I estimate it important to document the case.

Comment by Shing Wai Chan [ 11/Jul/13 ]

From https://glassfish.java.net/downloads/3.1.2.2-final.html , you may like to try GlassFish 3.1.2.2.

Generated at Thu Sep 29 07:08:03 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.