Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem calling EJB on one machine from an EJB on another machine  RSS feed

 
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
** I have a client connecting to a Central Server(CS)
** CS communicates to a Remote Server(RS) based on an Ip address that the client gives us.
So we basically get the context in a Session Bean(SB) by using the ip given, and then do a lookup for another SB on the RS. And i use the PortableRemoteObject.narrow to see if the object i get from the lookup can be Casted to the class that i have on my CS(these interfaces are exposed by the RS, as i do a lookup on them).
Now here i am getting a class cast exception, so i happened to take a printout of the object.toString(), instead of classcasting it as below.
Object obj = context.lookup("ActiveRemoteServer");
System.out.println("The Object is " + obj.toString());
Now that println gives me the same name of the class that i am trying to cast.
What could be the problem ??
I did the following ...
(1) In the ejb-jar.xml the SB on CS that is calling the SB on the RS has an <ejb-ref> defined to as the SB on the RS.
(2) I have included the RS package, (i mean the .jar) along with my CS .ear, as i will not be able to deploy the .Ear on CS with out that.
I am using JBoss3.0.4
One more thing is, i am not quite sure if (2) is right ? Becuz of (2) the beans and all that are there on RS are now deployed on the CS too.
TIA
Meka Toka
 
Vijayakumar Arya
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try by simply type casting the return object to the object of your destination.

Don't try PortableRemoteObject.narrow, it is a must to be implemented by all the RMI implementation that supports IIOP, but I am not very sure that whether the JNDI implementation of JBOSS has done that. Just have a try.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!