Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EJB3 client java.io.InvalidClassException

843830Feb 6 2008 — edited Feb 15 2008
Hello, I am new to Enterprise development and especially EJB3, I have looked every over the internet for a solution to this but to no avail. I'm using JBoss 4.2.2GA. Anyway, I deploy my entity and session beans properly and I verify that my session bean has started in Jboss's console.
************
So my session bean is :

package com;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.Serializable;
import com.EntityDB;
@Stateless
public class MainSessionBean implements Serializable, SessionBeanRemote{
@PersistenceContext
private EntityManager em;
static final long serialVersionUID = -5951007355563165335L;

public void setToDB(String in1, String in2)
{
EntityDB edb = new EntityDB();
edb.setName(in1);
edb.setPassword(in2);
em.persist(edb);
}
}
**********************
And its interface is
package com;
import javax.ejb.Remote;
import java.io.Serializable;
@Remote
public interface SessionBeanRemote extends Serializable{
static final long serialVersionUID = -1145492871624366669L;

public void setToDB(String in1, String in2);

}
*******************
my client code is

package test;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.SessionBeanRemote;
import java.io.Serializable;
public class MainTestClient implements Serializable{

static final long serialVersionUID = -3849529018242856585L;

public static void main(String[] args) {

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.jnp");
properties.put("java.naming.provider.url", "localhost:1099");
Context context=null;
try {
context = new InitialContext(properties);
Object o= context.lookup("MainSessionBean/remote");
Object j = null;
SessionBeanRemote beanRemote = (SessionBeanRemote)j;
beanRemote.setToDB("myUser","myPswrd");

} catch (NamingException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println("finished");
}
}
*****************************
whenever i run the client i get the exception
javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2711693270411201590, local class serialVersionUID = 1126421850898582900]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(Unknown Source)
at test.MainTestClient.main(MainTestClient.java:30)
Caused by: java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2711693270411201590, local class serialVersionUID = 1126421850898582900
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.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(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.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
... 3 more
Exception in thread "main" java.lang.RuntimeException: javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2711693270411201590, local class serialVersionUID = 1126421850898582900]
at test.MainTestClient.main(MainTestClient.java:37)
Caused by: javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2711693270411201590, local class serialVersionUID = 1126421850898582900]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(Unknown Source)
at test.MainTestClient.main(MainTestClient.java:30)
Caused by: java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2711693270411201590, local class serialVersionUID = 1126421850898582900
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.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(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.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
... 3 more
I apologize for the large nature of this post, but ive been dealing with this problem for several days now. The interesting things i have found is that even if i do not place the serialVersionUID's into all the classes i recieve the same exception. If i try to run this code on another machine running Jboss 4.2.2GA as well i get the same values, and if i try and make another project with similar code i get the same Error with the same serialVersionUID's, Im sure that is important but i cannot figure out what could be going wrong.
Thanks in advance for any responses
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2008
Added on Feb 6 2008
5 comments
1,107 views