• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error while calling EJB

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am creating a stateless session bean using JBoss 4 server and JDK 6.0

I receive the folowing error when I try to call the EJb from my Java Application

below is the trace i have attached my jboss.xml jndi and ejb-jar.xml.


Exception in thread "main" javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.session.BaseSessionRemoteProxy; local class incompatible: stream classdesc serialVersionUID = 8310915813626447181, local class serialVersionUID = 2609262789016232311]
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 client.Client.main(Client.java:26)
Caused by: java.io.InvalidClassException: org.jboss.ejb3.session.BaseSessionRemoteProxy; local class incompatible: stream classdesc serialVersionUID = 8310915813626447181, local class serialVersionUID = 2609262789016232311
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.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




<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<description>JBoss Stateless Session Bean Tutorial</description>
<display-name>JBoss Stateless Session Bean Tutorial</display-name>
<enterprise-beans>
<session>
<ejb-name>Calculator</ejb-name>
<remote>statelessExamples.CalculatorRemote</remote>
<local>statelessExamples.CalculatorLocal</local>
<ejb-class>statelessExamples.CalculatorBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>



<?xml version="1.0"?>
<jboss
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>Calculator</ejb-name>
<jndi-name>statelessExamples.CalculatorRemote</jndi-name>
<local-jndi-name>statelessExamples.CalculatorLocal</local-jndi-name>
</session>
</enterprise-beans>
</jboss>




package client;

import java.util.Properties;

import javax.naming.InitialContext;

import stateless.Calculator;
import stateless.CalculatorRemote;

public class Client {
public static void main(String[] args) throws Exception {

Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
p.put("java.naming.factory.url.pkgs",
"org.jboss.naming rg.jnp.interfaces");
p.put("java.naming.provider.url", "localhost:1099");

// System.setProperty("java.naming.factory.initial",
// "org.jnp.interfaces.NamingContextFactory");
// System.setProperty("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
// System.setProperty("java.naming.provider.url", "localhost:1099");

InitialContext ctx = new InitialContext(p);
Calculator calculator = (Calculator) ctx.lookup("statelessExamples.CalculatorRemote");

System.out.println("1 + 1 = " + calculator.add(1, 1));
System.out.println("1 - 1 = " + calculator.subtract(1, 1));
}
}



Thanks and Regards

Aadhar Sharma
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you have incorrect JBoss jar files in the classpath of the client. You should have the same JBoss jar files as what you have on the server. Copy the jbossall-client.jar file from the %JBOSS_HOME%/client folder to your application's (client's) classpath and remove the other JBoss jar files.
 
aadhar sharma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a Ton Jai

Worked out for me
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It fixed it for me too!

Basically the client application needs the jbossall-client.jar from the jboss server that the ejbs are deployed under. I had multiple JBoss instances so that make it hard to find out what was wrong.

You da man!

BTW, Aadhar, I didn't have to put anything in jboss.xml and ejb-jar.xml, all I did was this:



http://docs.jboss.org/ejb3/app-server/tutorial/jndibinding/jndi.html
[ February 24, 2008: Message edited by: Kelly Wei ]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Worked for me too. Thanks
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread helped me to solve some problems , but I am reviving this old post because-
Though getting the same jboss jar file in client as from server solved the issue , I am confused with the reason of this.
someone please through some light why is it so much dependent on server jars for a remote jndi lookup.
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because Client and Server communicate via serialized objects they need the same version of certain classfiles. The exception you got is about two different versions (detected via serialVersionUID).
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic