[jboss-user] [J2EE Design Patterns] - EJB3 and JBoss client java.io.InvalidClassException

SpawnOfLinkTIS do-not-reply at jboss.com
Wed Feb 6 15:16:09 EST 2008


Hello, I am relativly new to Enterprise development and especially EJB3, I have looked everywhere 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
  | 

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

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

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



More information about the jboss-user mailing list