Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication between two J2EE servers - Problems!

 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
My question is not about the SCBCD directly, but I hope you can help me anyway.
Here it goes:
I have set up two EJB - servers, with each different beans deployed on them. Now, by using a remote client I call a method on the first servers (so far so good) and in this method another method gets called on the second server; here is were the problems start. The lookup - part succeeds, so I assume the first server can locate the bean on the second server. But when I want to use the narrow statement on the PortableRemoteObject I get the following error message:
java.rmi.ServerException: java.rmi.ServerException: java.lang.NoClassDefFoundError: org/omg/stub/javax/ejb/_EJBHome_Stub
etc. ...
I have created a jar file with the necessary interfaces (and stubs) in it, so the first server should be able to call methods of second. I think I am missing something
Can any of you experts help me?
Thanks a lot!
 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You would also need client jar files of the second app server on the classpath of the first one. To be more clear, If you have server A which is trying to access server B, then alongwith the client jar files of the the EJB you are trying to access on server B, you will also need client jar file of server B. These files will go under a folder like lin of server A. You haven't mentioned what servers you are using, so can't help in that area.
HTH
Tejas
 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer, I am going to try your suggestion and keep you posted.
BTW I am using JBuilder 7, with Borland Enterprise Server 5.0.1
 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I was able to solve the noclassdeffounderror, but now ( ) a nasty classcast exception keeps me a wake at night.
This is my error now:
java.lang.ClassCastException: The class loader sun.misc.Launcher$ExtClassLoader@404536 is different from @5383266[PlutoEJBModule.jar]
at com.inprise.vbroker.rmi.CORBA.PortableRemoteObjectImpl.narrow(PortableRemoteObjectImpl.java:261)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at pluto_enterprise.GenericSessionBean.testMiddleTier(GenericSessionBean.java:2640)
at java.lang.reflect.Method.invoke(Native Method)
I tried to change the classloader policy on both partition servers from per_module to per_container, but no effect.
Anyone suggestions?
Thanks a lot!
Johan
 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am glad that you solved the NoClassDef... problem.
I am not sure about this problem, just a suggestion...
The stacktrace is complaining abt different class defs problem perhaps....
Your ejb jar file, does it have referenced library jar files included in them. To be more clear, your ejb jar file should not include any other jar files. All the jar files, the ejb needs should go to the lib folder of your app server.
HTH
Tejas
 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I can see that the code is using java reflection and is invoking a method from the stacktrace you have posted. If possible can you paste the code of the method being invoked...
It is possible that there is problem in the code inside the method being invoked.
Tejas
 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tejas,
Thanks for your responses, here is the code of the first server, which calls a method on the second server. The method on the second server is just a System.out.printnl("---"); nothing more.
public void testMiddleTier()
{
try
{
Context initContext = new InitialContext();
Object ref2 = initContext.lookup("JCPPBridgeBean");
//cast to Home interface
JCPPBridgeHome jCPPBridgeHome = (JCPPBridgeHome)PortableRemoteObject.narrow(ref2, JCPPBridgeHome.class);
JCPPBridge jCPPBridge = jCPPBridgeHome.create();
jCPPBridge.connectionCPPEngine();
}
// Bad catching here, but it is just a testing method
catch(Exception ex)
{
ex.printStackTrace();
}
}


Thx,
Johan
 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Your code fragment :
ontext initContext = new InitialContext();
Object ref2 = initContext.lookup("JCPPBridgeBean");
//cast to Home interface
Is JCPPBridgeBean the JNDI name to which your EJB is bound ?
Can you change it to something else and try again ? Looking at your class names JCPPBridgeBean could be the name of one of your classes. So may be the container gets confused, anyway try changing the name, and tell us what happens.
Thanks
Tejas
 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tejas,
Again thanks for your reply.
I changed the JNDI name but I'm still getting the same error (classcastexception).
I think it has something to do with different classloaders. Under the directory: "C:\JBuilder7\BorlandEnterpriseServer\var\servers\pc-johan\partitions\Distributed\lib" I placed two jar files, in one of these jars are also the home and remote interfaces (JCPPBridge and JCPPBridgeHome). I believe these are causing this problem, but if I remove them, the compiler complains about noclassdeffounderror (regarding the home interface). This is strange, because the rem. and home interface are also in the ejbmodule.
Can I force it to use only one classloader? Maybe I have to put the necessary -extra- jar(s) in some other directory?
I'm running out of ideas, I tougth multitier programming was a basic concept of J2EE technology and thus pretty transparent and programmer friendly (or maybe it is just me )
 
Johan Ruttens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I solved the problem: I just had to import the right package, with the right interfaces, and it WORKED!
Thanks everybody for your support
Johan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic