[jboss-dev-forums] [Design of JBoss Build System] - Re: [JBASMP-2] Create an Undeploy Mojo

guignome do-not-reply at jboss.com
Sun Oct 12 01:10:24 EDT 2008


This is a classloader problem. In java, an object created in a classloader cannot be cast to its superclass in another classloader. This is simply because two classes loaded using the same class name from the same jar from two different class loader are different (see Java Language Specification third edition-chapter 4.3.4).

In our case the deploy mojo creates a temporary classloader that contains jbossall-client.jar each time it does a jmx call. That's the source of the problem. I changed a bit the behaviour and store the temporary classloader as a static field. This way, classes from jbossall-client.jar are loaded only once per jvm.

That's a hack to fix a hack and I wouldn't be surprise if that was creating some other issues. Ideally, jbossall-client should be defined as a maven dependency (as described in the comments of the classloader hack).

Note that doing
$ export MAVEN_OPTS=-verbose
 and using java6 instead of java5 helps a lot to debug classloader issues.
I'll clean up my patch and send it soon.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4181665#4181665

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4181665



More information about the jboss-dev-forums mailing list