tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arshan Dabirsiaghi" <arshan.dabirsia...@aspectsecurity.com>
Subject Major Tomcat classloading issues with javaagent command line switch
Date Tue, 06 Apr 2010 04:04:23 GMT
Hi,

 

Has anybody had any success the "javaagent:" switch with Tomcat on the
command line? I've tested using Tomcat 5.5.28 and Tomcat 6.0, with both
JDK 1.5 and 1.6 through the Eclipse WTP plugin, and I always run into a
very peculiar problem. When using an agent, no servlets defined in the
web.xml work, even with an agent that does literally nothing due to a
NoClassDefFoundError. I've included a zipped-up Eclipse WTP project that
reproduces the issue.

 

Try running the project [1] on your own system with a javaagent switch
to an agent that does nothing (like /build/classes/aspect.jar in my
zip). Every time a servlet is visited, the following exception is
encountered:

 

javax.servlet.ServletException: Error allocating a servlet instance

 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:102)

 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2
93)

   ...

 

root cause:

 

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

   java.lang.ClassLoader.findBootstrapClass(Native Method)

   java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:892)

   java.lang.ClassLoader.loadClass(ClassLoader.java:302)

   java.lang.ClassLoader.loadClass(ClassLoader.java:300)

   sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

   java.lang.ClassLoader.loadClass(ClassLoader.java:252)

 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader
.java:1302)

 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader
.java:1233)

 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:102)

 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2
93)

 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:84
9)

 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:583)

 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)

   java.lang.Thread.run(Thread.java:619)

 

The bottom line appears to be this: across Tomcat and JDK versions, you
can't use the javaagent switch and have a working web app.

 

Steps to reproduce (for Tomcat 6, you might have to fiddle with the
project facet configs for Tomcat 5.5):

 

1. Download zip from http://i8jesus.com/stuff/JeffAgent.zip

2. Extract zip to <wherever>

3. In Eclipse (w/ WTP), import an existing project into your workspsace,
sourced at <wherever>

4. Go to Run Configurations

5. Select your Apache Tomcat 6 run configuration

6. Add -javaagent:<wherever>/build/classes/aspect.jar to the VM
arguments (and apply/save)

7. Add the JeffAgent project added in step #3 to the Tomcat server

8. Start the Apache server (through WTP)

9. Try visiting the servlet at http://localhost:8080/JeffAgent/Jeff

10. See the exception shown above

 

Now, to see why I'm really confused, take out the "javaagent" switch
added in step #6, restart the server, and see that the servlet operates
normally. 

 

Does anyone have any experiences to share using javaagent (or
instrumentation, period) on the big application servers? Although the
message indicates it's a simple classloading issue, debugging has proved
quite difficult. This is not the case of a misplaced servlet-api.jar, or
something to that effect. The mere presence of an agent makes the
servlet container incapable of finding many classes it would otherwise
be able to find.

 

Please help!

 

Thanks,

Arshan


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message