[jboss-user] [EJB 3.0] - Problem with Stateful EJB

violon do-not-reply at jboss.com
Tue Dec 12 04:23:24 EST 2006


I got a problem when developed a simple stateful EJB3. Can you help me to solve this problem. Thanks a lot.

This is remote interface :

  | package examples.session.stateful;
  | 
  | 
  | /**
  | * The business interface - a plain Java interface with only
  | * business methods.
  | */
  | 
  | public interface Count {
  | 	/**
  | 	 * Increments the counter by 1
  | 	 */
  | 	public int count();
  | 	/**
  | 	 * Sets the counter to val
  | 	 * @param val
  | 	 */
  | 	public void set(int val);
  | 	/**
  | 	 * removes the counter
  | 	 */
  | 	public void remove();
  | 
  | }
  | 

And this is Bean class :

  | package examples.session.stateful;
  | 
  | import javax.ejb.Remote;
  | import javax.ejb.Remove;
  | import javax.ejb.Stateful;
  | 
  | @Stateful
  | @Remote(Count.class)
  | public class CountBean implements Count {
  | 
  | 	/** The current counter is our conversational state. */
  | 	private int val;
  | 	
  | 	/**
  | 	* The count() business method.
  | 	*/
  | 	public int count() {
  | 		System.out.println("count()");
  | 		return ++val;
  | 	}
  | 	
  | 	/**
  | 	* The set() business method.
  | 	*/
  | 	public void set(int val) {
  | 		this.val = val;
  | 		System.out.println("set()");
  | 	}
  | 	
  | 	/**
  | 	* The remove method is annotated so that the container knows
  | 	* it can remove the bean after this method returns.
  | 	*/
  | 	@Remove
  | 	public void remove() {
  | 		System.out.println("remove()");
  | 	}
  | }
  | 

And test client :

  | package examples.test.stateful;
  | 
  | import java.util.Properties;
  | 
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | 
  | import examples.session.stateful.Count;
  | 
  | public class CountClient {
  | 
  | 	/**
  | 	 * @param args
  | 	 */
  | 	public static void main(String[] args) {
  | 		// TODO Auto-generated method stub
  | 		Properties properties = new Properties();
  | 		properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | 		properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
  | 		properties.put("java.naming.provider.url","localhost:1099");
  | 		
  | 		Context ctx;
  | 		try {
  | 			ctx = new InitialContext(properties);
  | 			Count obj =  (Count) ctx.lookup("CountBean/remote");
  | 			System.out.println(obj);
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 
  | }
  | 

This is the problem :

  | Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/jboss/invocation/Invoker;
  | 	at java.lang.Class.getDeclaredFields0(Native Method)
  | 	at java.lang.Class.privateGetDeclaredFields(Unknown Source)
  | 	at java.lang.Class.getDeclaredField(Unknown Source)
  | 	at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
  | 	at java.io.ObjectStreamClass.access$600(Unknown Source)
  | 	at java.io.ObjectStreamClass$2.run(Unknown Source)
  | 	at java.security.AccessController.doPrivileged(Native Method)
  | 	at java.io.ObjectStreamClass.<init>(Unknown Source)
  | 	at java.io.ObjectStreamClass.lookup(Unknown Source)
  | 	at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
  | 	at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
  | 	at java.io.ObjectInputStream.readClassDesc(Unknown Source)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject0(Unknown Source)
  | 	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
  | 	at java.io.ObjectInputStream.readSerialData(Unknown Source)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject0(Unknown Source)
  | 	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
  | 	at java.io.ObjectInputStream.readSerialData(Unknown Source)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject0(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject(Unknown Source)
  | 	at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
  | 	at java.io.ObjectInputStream.readExternalData(Unknown Source)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject0(Unknown Source)
  | 	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
  | 	at java.io.ObjectInputStream.readSerialData(Unknown Source)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject0(Unknown Source)
  | 	at java.io.ObjectInputStream.readObject(Unknown Source)
  | 	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:41)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
  | 	at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:34)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
  | 	at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:46)
  | 	at $Proxy0.createProxy(Unknown Source)
  | 	at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
  | 	at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
  | 	at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
  | 	at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
  | 	at javax.naming.InitialContext.lookup(Unknown Source)
  | 	at examples.test.stateful.CountClient.main(CountClient.java:25)
  | 

please, help me as soon as possible.

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

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



More information about the jboss-user mailing list