2 Replies Latest reply on Nov 30, 2007 12:39 PM by joearmstrong

    getInitialContext with Stateful session bean throws exceptio

    joearmstrong

      I am running JBoss 4.0.4.GA using Java 1.6 and am getting the following exception:

      Exception in thread "main" java.lang.RuntimeException: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
      at com.titan.clients.TravelAgentShell.getAgent(TravelAgentShell.java:35)

      at com.titan.clients.TravelAgentShell.cabin(TravelAgentShell.java:163)
      at com.titan.clients.TravelAgentShell.processCommand(TravelAgentShell.ja
      va:94)
      at com.titan.clients.TravelAgentShell.shell(TravelAgentShell.java:70)
      at com.titan.clients.TravelAgentShell.main(TravelAgentShell.java:22)
      Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
      at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingC
      ontext.java:1150)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at com.titan.clients.TravelAgentShell.getAgent(TravelAgentShell.java:33)

      ... 4 more
      Caused by: java.lang.reflect.UndeclaredThrowableException
      at $Proxy1.createProxy(Unknown Source)
      at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:3
      04)
      at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java
      :1125)
      at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingC
      ontext.java:1142)
      ... 8 more
      Caused by: java.lang.ClassNotFoundException: [Lorg.jboss.aop.advice.Interceptor;

      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      [rest of stack deleted for brevity]

      The client code segment I have is:

      private TravelAgentRemote getAgent()
      {
      try
      {
      agent = (TravelAgentRemote)getInitialContext().lookup("TravelAgentRemote");
      }
      catch (Exception ex){ throw new RuntimeException(ex);}
      return agent;
      }

      and the session bean definition is:

      @Stateful
      @RemoteBinding(jndiBinding="TravelAgentRemote")
      public class TravelAgentBean implements TravelAgentRemote {...}

      If I change the session bean to be Stateless the client code works fine - what is different in JNDI naming for Stateless vs. Stateful session beans ?

      Also, it has been reported to me (although not verified) that this code works fine with Java 1.5.

      If you want to see the whole set of source, it is the source from Chpt. 11.4 from the O'reilly book "Enterprise Java Beans 3.0" by Burke & Monson-Haefel (ISBN-13: 978-0-596-00978-6).

      Any insights would be appreciated.

      Thanks.

      Joe