users@glassfish.java.net

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

From: Sahoo <Sahoo_at_Sun.COM>
Date: Wed, 22 Oct 2008 09:40:27 +0530

There are two ways:

1. You can duplicate all the client view classes in both the ear files.
Client view classes include remote interface and its transitive closure.

2. Create a jar file called common.jar with all client view classes,
place it in domain_dir/lib/applibs. You don't have to package client
view classes in any of the ear files. While deploying both the apps, use
--libraries option like this:
'asadmin deploy --libraries=common.jar app1.ear'
'asadmin deploy --libraries=common.jar app2.ear'
I have not tried this myself, but I think this should work. Let us know
how it goes.

Option #2 will lead to sharing of classes.

Thanks,
Sahoo

Sebastian Hofmann wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>