title: ClassNotFoundException with java agent (-javaagent:jarpath)
body: <p>The root of my problem is that I'm trying to use the SizeOf <a href="http://sourceforge.net/projects/sizeof/" rel="nofollow">sourceforge project</a> from a web application deployed on JBoss AS7 and getting a <code>ClassNotFoundException</code> for <code>net.sourceforge.sizeof.SizeOf</code>. I added <code>-javaagent:/path_to_jar/SizeOf.jar</code> to the server's <code>JAVA_OPTS</code> and see the <code>System.out.println</code> from the premain method on server startup (JAVAGENT: call premain instrumentation for class SizeOf). However, when I try to call <code>SizeOf.sizeOf(obj)</code> from my servlet's doGet method, the application fails with the aforementioned <code>ClassNotFoundException</code>.</p>
  
  <p>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 <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html" rel="nofollow">the offical JVM docs</a>, 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?</p>