0 Replies Latest reply: Mar 5, 2012 3:53 AM by Bernd Zeitler RSS

Classloading issue with custom LoginModules and Principal implementation deployed in EAR

Bernd Zeitler Expert

I am migrating a large J2EE application from JBoss 4.2.3 (and JBoss 4.3) to JBoss 6.1.

 

We implemented our own ClientLoginModule along with the matching ServerLoginModule and a custom Principal. I tried to deploy these within an EAR, along with a my-jboss-beans.xml, where the application policy is configured.

The EAR contains an EJB (J2EE) which is secured with this policy.

 

When calling the bean from a remote client, I get the following exception:

 

{code}

2012-03-02 15:46:39,548 ERROR [org.jboss.remoting.transport.socket.ServerThread] (WorkerThread#0[127.0.0.1:54670]) WorkerThread#0[127.0.0.1:54670] exception occurred during first invocation: java.lang.ClassNotFoundException: test.me.MyPrincipal

    at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [:1.6.0_29]

    at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_29]

    at java.net.URLClassLoader.findClass(URLClassLoader.java:190) [:1.6.0_29]

    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [:1.6.0_29]

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [:1.6.0_29]

    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [:1.6.0_29]

    at java.lang.Class.forName0(Native Method) [:1.6.0_29]

    at java.lang.Class.forName(Class.java:247) [:1.6.0_29]

    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:304) [jboss-classloader.jar:2.2.1.GA]

    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1172) [jboss-classloader.jar:2.2.1.GA]

    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:886) [jboss-classloader.jar:2.2.1.GA]

    at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:505) [jboss-classloader.jar:2.2.1.GA]

    at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:450) [jboss-classloader.jar:2.2.1.GA]

    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [:1.6.0_29]

    at java.lang.Class.forName0(Native Method) [:1.6.0_29]

    at java.lang.Class.forName(Class.java:247) [:1.6.0_29]

    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603) [:1.6.0_29]

    at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:172) [:]

    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574) [:1.6.0_29]

    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) [:1.6.0_29]

    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) [:1.6.0_29]

    at java.util.HashSet.readObject(HashSet.java:291) [:1.6.0_29]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_29]

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_29]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_29]

    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_29]

    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) [:1.6.0_29]

    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) [:1.6.0_29]

    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) [:1.6.0_29]

    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) [:1.6.0_29]

    at org.jboss.invocation.MarshalledInvocation.readExternal(MarshalledInvocation.java:665) [:6.1.0.Final]

    at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) [:1.6.0_29]

    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) [:1.6.0_29]

    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) [:1.6.0_29]

    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) [:1.6.0_29]

    at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238) [:]

    at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138) [:]

    at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123) [:]

    at org.jboss.invocation.unified.marshall.InvocationUnMarshaller.read(InvocationUnMarshaller.java:59) [:6.1.0.Final]

    at org.jboss.remoting.transport.socket.ServerThread.versionedRead(ServerThread.java:900) [:]

    at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:754) [:]

    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744) [:]

    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548) [:]

    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [:]

{code}

 

JBoss 6.1 is coming with JBoss Remoting 2.5.4 SP2 (don't ask me, why you can't see this on the stack trace).

I did some debugging and found out, that ObjectInputStreamWithClassLoader#resolveClass has not the EAR classloader configured. Its classloader is null why the base classloader is used.

 

I tried the same deployment with an unsecured EJB, passing a pricipal instance as parameter: no problem at all.

I event tried to configure a different classloading behaviour for the EAR, with no success at all.

 

Do I have to do some more configuration or is this a bug, probably in remoting?

 

Regards,

 

Bernd