Reputation: 21
The root of my problem is that I'm trying to use the SizeOf sourceforge project from a web application deployed on JBoss AS7 and getting a ClassNotFoundException
for net.sourceforge.sizeof.SizeOf
. I added -javaagent:/path_to_jar/SizeOf.jar
to the server's JAVA_OPTS
and see the System.out.println
from the premain method on server startup (JAVAGENT: call premain instrumentation for class SizeOf). However, when I try to call SizeOf.sizeOf(obj)
from my servlet's doGet method, the application fails with the aforementioned ClassNotFoundException
.
If anyone can tell me how to get this working with JBoss AS7, that would be helpful (I have it working in an Eclipse run configuration -- the equivalent of running from the command line). What I would really like to do, above and beyond that, is to understand how classloading works for Java Agents. The best documentation I've been able to find is in the offical JVM docs, and that's pretty sparse. All it says about classloading is that the Premain-Class will be loaded by the system classloader. I saw a blog post that suggested that the jar didn't need to be placed on the classpath, since the -javaagent JVM argument would take care of that, so it would appear that I shouldn't have to add the SizeOf jar as a AS7 module. Am I missing something?
Upvotes: 0
Views: 2028
Reputation: 21
Need to do the following:
Upvotes: 2