[ http://jira.jboss.com/jira/browse/JBAS-1283?page=comments#action_12316704 ] Tomislav Bodor commented on JBAS-1283: --------------------------------------
This is quite a significant problem with farther reaching consequences than just JSP compilation. It affects all versions of JBoss from 3.2.6 onwards (possibly earlier). 3.2.3 is not affected, possibly due to use of Tomcat 4 or maybe due to a class loading bug that was fixed in 3.2.4 (I can find a reference if needed). But in 3.2.3 scoping is broken for other reasons and this overriding has no chance of working anyway. 4.0.2RC1 is affected as well. It does not only affect overriding dom4j but also any other package that makes use of the thread context class loader to locate classes (e.g. xerces). Basically, what is happening is that a worker thread starts of as having as thread context class loader the loader that is responsible for loading Tomcat sar. However, somewhere along the way (in ...catalina.core.StandardHostValve) Tomcat changes the context class loader to be the one responsible for loading classes from the deployed war file from which the JSP is loaded. After that point, any piece of code like: (DocumentBuilderFactory) DocumentBuilderFactory.newInstance() will cause a ClassCastException as the right hand side uses thread context class loader to load the DocumentBuilderFactory implementation from the war file (assuming it is overriden there and scoping is enabled), but the left hand side (the cast) specifies class loaded by the sar class loader (actually, by a parent of that loader - the class eventually comes from $(JBOSS_HOME}/lib/xercesImpl.jar in this example). Other similar scenarios fail, too - as long as Tomcat attempts to (say) parse an XML file between the StandardHostValve and the invocation of the servlet that is the target of the request. Basically, the context class loader is changed too early (though the fix may be more complicated). Finally, setting java2ParentDelegation to true does seem to fix the problem at the first glance, but in fact what it does is cause the DocumentBuilderFactory implementation in the above example to be also loaded from the JBoss's copy of xercesImpl.jar. So no ClassCastException, but also no overriding! Might as well turn off scoping and remove overriden libraries from the war file. Of course, if the application requires them, it stops working. Hardly what we want. So... Can I please ask you to raise the priority on this one? Perhaps even restructure the bug report so it doesn't appear as related to JSP only, but to scoping and class loading? I'm also happy to work with anyone there on fixing this as this is quite critical for us. Regards, Tomislav > Tomcat Unable to Compile JSPs when Separate ClassLoader Namespace Used for > Webapp > --------------------------------------------------------------------------------- > > Key: JBAS-1283 > URL: http://jira.jboss.com/jira/browse/JBAS-1283 > Project: JBoss Application Server > Type: Bug > Components: Web (Tomcat) service > Versions: JBossAS-3.2.6 Final > Environment: Stock JBoss 3.2.6 running on Linux (kernel 2.4.26), Sun JDK and > JRE version 1.4.2_04 > Reporter: Jeremy Brown > Assignee: Anil Saldhana > Priority: Minor > Attachments: test.war > > > See my initial forum post at > "http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3861452#3861452". > The dom4j libs provided by JBoss do not work correctly with my web > application, so I attempted to configure my webapp's "jboss-web.xml"--as per > the wiki page at > "http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration"--so that > my webapp would essentially be in a different classloader namspace and would > be able to override the server dom4j implementation with its own. Now, > Tomcat bails out during JSP compilation with a dom4j-related > ClassCastException, leading me to believe there might some problem with the > sort of setup I'm trying to attempt...for example, Tomcat's JSP compiler > might be trying to link with the dom4j in my application's namespace while > its classes have been loaded next to (and probably are already using) dom4j > in the server namespace. > I'll attach a .war file exhibiting this behavior to this bug report. > Here's the specific exception for this .war file: > java.lang.ClassCastException > at > javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:93) > at > org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:91) > at > org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:70) > at org.apache.jasper.compiler.JspConfig.init(JspConfig.java:188) > at > org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:240) > at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:160) > at org.apache.jasper.compiler.Compiler.compile(Compiler.java:470) > at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451) > at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) > at > org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511) > at > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295) > at > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) > at > org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) > at > org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) > at > org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) > at > org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:158) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) > at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) > at > org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) > at java.lang.Thread.run(Thread.java:534) > Interestingly enough, I can copy my app-specific "dom4j-full.jar" over the > JBoss-provided "dom4j.jar" in "/lib", and everything works great. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ JBoss-Development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-development
