2 Replies Latest reply on Jan 19, 2007 5:59 PM by Nicolas Carranza

    Stateful session with remote client problem

    john ware Newbie

      Hi,
      I'm using jboss-4.0.5.GA and jboss-EJB-3.0_RC9_Patch_1 and I'm getting an error when the client does the context lookup. My local interface works fine.

      I'm getting a "java.lang.ClassNotFoundException: [Lorg.jboss.aop.advice.Interceptor". I found that class in jboss-aop-jdk50.jar and I know that it is in my classpath.

      thanks in advance,
      john

      The source code is below the shell listing

      main 1.0
      main 1.1 context lookup using: JWStatefull/ShoppingCartBean/remote
      Exception
      javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
      at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.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 sfsb.Client.main(Client.java:17)
      Caused by: java.lang.reflect.UndeclaredThrowableException
      at $Proxy0.createProxy(Unknown Source)
      at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
      at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
      at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
      ... 4 more
      Caused by: java.lang.ClassNotFoundException: [Lorg.jboss.aop.advice.Interceptor;
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:50)
      at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:139)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
      at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:122)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
      at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
      at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
      at org.jboss.remoting.Client.invoke(Client.java:525)
      at org.jboss.remoting.Client.invoke(Client.java:488)
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)




      Here is the source code:


      
      /////////////////////////////////
      // Client.java
      package sfsb;
      import java.util.HashMap;
      import java.util.Properties;
      import javax.naming.InitialContext;
      
      public class Client
      {
       final static String jndiName = "JWStatefull/ShoppingCartBean/remote";
       public static void main(String[] args)
       {
      
       try{
       System.out.println( "main 1.0" );
       InitialContext ctx = new InitialContext();
       System.out.println( "main 1.1 context lookup using: " + jndiName );
       ctx.lookup( jndiName );
       Object obj = null;
       System.out.println( "main 1.2" );
       System.out.println( obj.toString() );
       ShoppingCart cart = (ShoppingCart) obj;
       System.out.println( "main 1.3" );
       }catch( Exception e ){
       System.out.println( "Exception " );
       e.printStackTrace();
       System.exit(-1);
      
       }
      
       }
      }
      
      
      
      /////////////////////////////////
      // ShoppingCart.java
      
      
      
      package sfsb;
      
      import java.util.HashMap;
      import javax.ejb.Remove;
      
      public interface ShoppingCart
      {
       void buy(String product, int quantity);
      
       HashMap<String, Integer> getCartContents();
      
       @Remove void checkout();
      }
      
      
      /////////////////////////////////////
      // ShoppingCartBean.java
      
      package sfsb;
      
      import java.io.Serializable;
      import java.util.HashMap;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.ejb.Local;
      import javax.ejb.Remote;
      
      import org.jboss.annotation.ejb.LocalBinding;
      import org.jboss.annotation.ejb.RemoteBinding;
      
      
      @Remote
      @Local
      @LocalBinding ( jndiBinding="JWStatefull/ShoppingCart" )
      @Stateful
      
      public class ShoppingCartBean implements ShoppingCart, Serializable
      {
       private HashMap<String, Integer> cart = new HashMap<String, Integer>();
      
      
       public void buy(String product, int quantity)
       {
       if (cart.containsKey(product))
       {
       int currq = cart.get(product);
       currq += quantity;
       cart.put(product, currq);
       }
       else
       {
       cart.put(product, quantity);
       }
       }
      
       public HashMap<String, Integer> getCartContents()
       {
       return cart;
       }
      
       @Remove
       public void checkout()
       {
       System.out.println("To be implemented");
       }
      }