Hello all,
I have deployed a stateless session bean into JBoss 3.2.1. I am using the JaCORB naming service. When I obtain a reference to an Object from the InitialContext, PortableRemoteObject.narrow() fails on it with a ClassCastException.
Here is the jndi.properties I am using:
java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory java.naming.provider.url=IOR:000000000000002B49444C3A6F6D672E6F72672F436F734E616D696E672F4E616D696E67436F6E746578744578743A312E300000000000020000000000000068000102000000000C31302E33312E382E323134000DC80000000000114A426F73732F4E616D696E672F726F6F74000000000000020000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000010000002C0000000000000001000000010000001C00000000000100010000000105010001000101090000000105010001
Here is the code:
InitialContext context = new InitialContext(); Object obj = context.lookup( "ejb/UserWeek" ); System.out.println( obj.getClass().getClassLoader() ); System.out.println( UserWeekRemoteHome.class.getClassLoader() );
UserWeekRemoteHome home = ( UserWeekRemoteHome )
PortableRemoteObject.narrow (
obj, UserWeekRemoteHome.class );The code is executing as a JUnit test case, but in the textui.TestRunner, not the Swing one. I have already read a posting saying that the JUnit gui TestRunners have their own special ClassLoader and it can cause exactly this kind of problem because it won't be the same ClassLoader that the test (client) code obtained its definition of the remote interface from. Also, I am executing this test from an Ant task but with fork="yes".
The result of the two lines to standard out is that the object returned from the lookup() has a NULL reference to its ClassLoader, whereas the class definition loaded by the client code executing in the JUnit task is Sun's AppClassLoader.
I realize that this question is probably not JBoss specific. I'm not entirely sure how this is working behind the scenes. I don't know what CNCtxFactory is doing or why it would be loading from a different ClassLoader, or why the raw object returned from lookup() is null. Does anyone have any hints? I would appreciate it!
Many thanks, Adam
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
