Achieving isolation in 6.0.0.M5
gwzoller Oct 6, 2010 2:55 AMHello,
I'm getting a strange ClassNotFoundException I believe is related to classloaders on JBoss 5.1, 6.0.0 M4/5 (really mostly interested in 6).
I am running an EAR in which I've included a jboss-app.xml file in the ear's META-INF directory to ensure it has a separate classloader (?).
Contents of this file are:
<jboss-app>
<loader-repository>
com.stuff.profile:archive=Foo.ear
</loader-repository>
</jboss-app>
My EAR contains:
FooEJB.jar
FooClient.jar (contains interfaces like FooLocal I'm interested in below)
Foo.war (web app for the EAR that can make local calls into the EJB using interfaces found in FooClient.jar)
I inject the EJB in my WAR code thus: (in a ServletContextListener)
@EJB(name="profile")
private FooLocal profile = null;
Then use it a little later in this code like this:
System.out.println("Before reload: "+profile);
profile.doSomething();
My Output:
Before reload: Proxy to jboss.j2ee:ear=Foo.ear,jar=FooEjb.jar,name=profile,service=EJB3 implementing [interface com.stuff.profile.FooLocal]
...
<Clip--preamble exceptions>
...
09:57:13,764 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: com.stuff.profile.FooLocal
09:57:13,764 ERROR [STDERR] at java.net.URLClassLoader$1.run(Unknown Source)
09:57:13,764 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
09:57:13,764 ERROR [STDERR] at java.net.URLClassLoader.findClass(Unknown Source)
09:57:13,764 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
09:57:13,764 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
09:57:13,764 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
09:57:13,764 ERROR [STDERR] at java.lang.Class.forName(Unknown Source)
09:57:13,764 ERROR [STDERR] at org.jboss.ejb3.common.classloader.PrimitiveAwareClassLoader.findClass(PrimitiveAwareClassLoader.java:105)
09:57:13,764 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
09:57:13,764 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
09:57:13,764 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:307)
09:57:13,764 ERROR [STDERR] ... 28 more
So the injection worked! I get a proxy to the local interace I wanted--but it dies trying to marshal the class.
Here's the kicker: I've got two EARs constructed in essentially identical fashion differeing by their names and loader-repositories.
If I only put one of these EARs in my JBoss deploy directory everything works! If I add the other EAR (which alphabetically precedes
Foo.ear so it loads first), the first EAR works and I get these exceptions on the second.
I'm baffled. I'm dabbling in the dark art of classloader isolation--and not knowing what I'm doing.
Any ideas greatly appreciated!
Greg
-
Classloader Help.zip 5.6 MB