tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41011] New: - duplicate class definition error when JSPs loaded from multiple threads
Date Tue, 21 Nov 2006 22:22:25 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41011>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41011

           Summary: duplicate class definition error when JSPs loaded from
                    multiple threads
           Product: Tomcat 5
           Version: 5.5.17
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: crv@itasoftware.com


After switching to a client configuration where two JSP pages are loaded
simultaneously, I started getting LinkageErrors 10-20% of the time after
restarting Tomcat.  By passing -verbose:class to the JVM, I discovered that:

1. If the JSP classes and their dependencies are loaded one at a time,
everything is fine.

2. If the same classes are loaded concurrently in different threads, some of the
dependencies may be loaded twice.  In this case the -verbose:class output shows
a class loaded twice from the same location.

This tends to happen to me with the Struts Tiles classes, which are used by both
JSPs.  The first JSP starts loading its classes:

[Loaded org.apache.jsp.WEB_002dINF.include.xxx.pages.sidebar_jsp from
file:/xxx/catalina-base/work/Catalina/localhost/_/]
[Loaded org.apache.struts.taglib.tiles.PutTagParent from
file:/xxx/repository/struts/struts/1.2.9/struts-1.2.9.jar]
[Loaded org.apache.struts.taglib.tiles.PutListTagParent from
file:/xxx/repository/struts/struts/1.2.9/struts-1.2.9.jar]
...

The second JSP starts loading before the first finishes:

[Loaded org.apache.jsp.WEB_002dINF.include.xxx.pages.welcome_jsp from
file:/xxx/catalina-base/work/Catalina/localhost/_/]
[Loaded org.apache.struts.taglib.tiles.InsertTag$InsertHandler from
file:/xxx/repository/struts/struts/1.2.9/struts-1.2.9.jar]

One of the Tiles classes ends up being loaded twice:

[Loaded org.apache.struts.taglib.tiles.PutTag from
file:/xxx/repository/struts/struts/1.2.9/struts-1.2.9.jar]
[Loaded org.apache.struts.taglib.tiles.PutTag from
file:/xxx/repository/struts/struts/1.2.9/struts-1.2.9.jar]

The second JSP pages fails to render:

2006-11-21 11:32:49,617 [http-8080-Processor3] ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[jsp] -
Servlet.service() for servlet jsp threw exception
java.lang.LinkageError: duplicate class definition:
org/apache/struts/taglib/tiles/PutTag
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:880)
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
	at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:127)
	at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at
org.apache.jsp.WEB_002dINF.include.xxx.pages.welcome_jsp._jspx_meth_tiles_put_0(welcome_jsp.java:135)
	at
org.apache.jsp.WEB_002dINF.include.xxx.pages.welcome_jsp._jspx_meth_tiles_insert_0(welcome_jsp.java:109)
	at
org.apache.jsp.WEB_002dINF.include.xxx.pages.welcome_jsp._jspService(welcome_jsp.java:79)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
	at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
	at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
	at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
	at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
	at
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
	at
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
	at
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at xxx.ResponseHeaderInserter.doFilter(ResponseHeaderInserter.java:62)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:613)

The error seems to be recoverable, ie. I can hit refresh and it works.  I see
that there have been some WebappClassLoader synchronization issues in the past.
 I've only tried 5.5.17, but I don't think recent fixes were related (maybe
revision 469360?).

I'm using a custom Loader (to load jars from outside of WEB-INF/lib), but it
just wraps a normal WebappLoader(getContainer().getParentClassLoader()) and
calls addRepository with file URLs.  I don't think it's related to this situation...

Java version:
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_08-b03, mixed mode)

Thanks!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message