tags:

views:

78

answers:

2

Hi,

i have deployed two EARs on one server. i want to access one method in one java class in EAR to another java class in second EAR.

what are different ways to achieve this. which one is best way to do.

Thanks

A: 

Expose it as a web service and consume it in the other app.

Your application server may allow sharing the JNDI context, and thus you can obtain the required class by JNDI lookup, but I wouldn't recommend. This would mean your two ears will have to always live within the same app server (or cluster).

Bozho
which approach would you recommend using for letting EAR 1 know about the web service in EAR 2? A shared WSDL? (using what hostname?) A localhost-only URL for a REST service?
Thorbjørn Ravn Andersen
whatever is easier. Both options you suggested are viable.
Bozho
+1  A: 

I would simply use a Stateless Session Bean to expose this method to another (remote) Java application.

Exposing your method as a web serices would also work... but I don't really see the point of using web services between two Java applications. The marshalling of objects to XML and of XML to objects would consume CPU cycles for nothing if there is no need for a language agnostic protocol (which is the case between two Java applications).

Pascal Thivent