[jboss-user] [JBoss Remoting Users] - JNDI Lookup in multi-classloader environment

praveenbalaji do-not-reply at jboss.com
Wed Sep 9 15:26:17 EDT 2009

Software Version: JBoss Client from JBoss 4.2.2 drop.

I'm trying to do a JNDI lookup of a JMS Connection Factory in my component. This is a plain Java component. Several of my componnets can run in the same JVM under different classloaders. I'm loading jboss client jars in each of these component classloaders such that each classloader has its own copy of client jars. Each component does a JNDI lookup for the same named object.

The second (and consequent) component that does a lookup fails with a ClassCastException. The second component is looking up an object created by the first component. Though the classname matches, the classloader is different and hence the ClassCastException.

  | caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.ClassCastException: org.jboss.naming.LinkRefPair]
  | 	at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1298)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:763)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
  | 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
  |         ...
  |         ...
  | 	at sun.rmi.transport.Transport$1.run(Transport.java:153)
  | 	at java.security.AccessController.doPrivileged(Native Method)
  | 	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
  | 	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
  | 	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
  | 	at java.lang.Thread.run(Thread.java:595)
  | Caused by: java.lang.ClassCastException: org.jboss.naming.LinkRefPair
  | 	at org.jboss.naming.LinkRefPairObjectFactory.getObjectInstance(LinkRefPairObjectFactory.java:66)
  | 	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
  | 	at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1273)
  | 	at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1290)
  | 	... 70 more

I looked at the JBoss code and the object returned by the lookup at org.jnp.interfaces.NamingContext.lookup(javax.naming.Name) (line 667) is fetching the offending object.

Is there a way to provide isolation at component level in the client code? I see there is a way to do it for components (enterprise applications) running under the J2EE container as stated at http://www.jboss.org/community/wiki/classloadingconfiguration

Please note that unfortunately for me, it is not an option for me to load the jboss client jars under the JRE's ext classloader which is the ancestor of all my component classloaders. I have to provide isolation at the component level.


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

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

More information about the jboss-user mailing list