Skip to main content

GlassFish 4 and JVM Agent Classloader Visibility

No replies
quartzdesk
Offline
Joined: 2013-06-28
Points: 0

Hello,
I have a web-application (WAR) application that makes use of a JVM agent (my implementation). While porting the web-application to GlassFish 4 I bumped into a problem with the web-application not seeing the JVM agent classes on its classpath. When starting the web-application I keep getting a ClassNotFoundException for a class that is bundled in the JVM agent.

In the logs I can see the JVM agent being successfully initialized so no problem here.

This is the classloader hierarchy as logged by my JVM agent. You can see that the JVM agent is loaded by a classloader that also loads the glassfish.jar. I need this classloader to be available in the web-application classloader chain.

[2013-07-17 12:05:38,385] I [main] [MyAgent] - Agent class-loader info:
sun.misc.Launcher$AppClassLoader@3d637d45
file:/D:/Java/glassfish4/glassfish/modules/glassfish.jar
file:/D:/Java/glassfish4/glassfish/lib/monitor/flashlight-agent.jar
file:/D:/var/my-agent.jar !!! THIS IS MY AGENT JAR !!!
sun.misc.Launcher$ExtClassLoader@4eb55c7f (parent classloader of the above classloader)
file:/D:/Java/Jdk1.7/jre/lib/ext/access-bridge-64.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/dnsns.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/jaccess.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/localedata.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/sunec.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/sunjce_provider.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/sunmscapi.jar
file:/D:/Java/Jdk1.7/jre/lib/ext/zipfs.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/db2jcc4.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/db2jcc_license_cu.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/mysql-connector-java-5.1.23-bin.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/ojdbc6.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/postgresql-9.2-1002.jdbc4.jar
file:/D:/Java/glassfish4/glassfish/domains/domain1/lib/ext/sqljdbc4.jar

I searched in the GlassFish Admin Console for applicable classloading settings, but did not find anything.

BTW: This problem does not occur on Tomcat, nor on IBM WebSphere where web-applications can normally see classes in the entire classloader hierarchy up to the JVM bootstrap classloader.

Thanks for any hints,
Jan