users@glassfish.java.net

[Fwd: EJB remote communication between two applications within same server]

From: Sebastian Hofmann <sebastian.hofmann_at_sourcepark.de>
Date: Tue, 21 Oct 2008 14:49:16 +0200

Hi,

I have two enterprise applications (two ear's containing one ejb-jar
each) running in the same server. Now one bean of app1 should call a
method of a bean in app2.

I have created a bean (HelloBean) in app2 with a remote interface
(HelloRemote) implementing a method "public String sayHello()" and
annotated the interface with @Remote. The bean in app1 should call this
method, so I created a bean in app1 with a reference "private
HelloRemote helloRemote" and annotated the reference with @EJB. So far,
so good.

Thus my app1 now has a compiletime dependency to app2, because of the
interface "HelloRemote". When deploying the two ears into the server, I
get a ClassNotFoundException for this interface in app1. That seems to
be correct since applications are separated by different classloaders...

Now my question is, how to proceed in this case!? Do I have to duplicate
the remote interface so that the class file of this interface exists in
both ear's? And what should be done if the remote method should return a
custom class object? Is there a way of sharing classes between two
applications or has each common class to be duplicated? Or am I totally
wrong? ;-)

Thanks for advice...
Sebastian