3

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

ajay
  • 31
  • 2
  • Check the solution which works at least on Glassfish v3: http://stackoverflow.com/questions/13512028/glassfish-2-1-ejb-3-0-exposing-local-ejb-to-other-applications-running-in-the-sa/13652620#13652620 – MeTTeO Dec 04 '12 at 09:40

2 Answers2

2

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
  • 562,542
  • 136
  • 1,062
  • 1,124
0

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
  • 588,226
  • 146
  • 1,060
  • 1,140