Monday, December 30, 2013

I understood that Local interface is designed for clients in the same container's JVM instance and remote interface is designed for clients residing outside the EJB container's JVM. How about the web application client which is not reside (or packaged) in the same .ear but reside on the same Java EE server?
share|improve this question
2 
Why wouldn't you put the webapp in the same EAR? The point of an EAR is precisely to contain both the web and EJB parts of an application. –  JB Nizet Dec 15 '11 at 20:34
 
What do you mean by the same J2EE server? Is it deployed on the same instance, in the same domain?–  jFrenetic Dec 15 '11 at 20:35
 
EAR is maintained and deployed separately and other WAR wants to use some business methods from the ejb reside in the EAR. J2EE server means they will be deployed on the same instance. –  Thurein Dec 15 '11 at 21:00 
 
In my case, on Glassfish 3.1, deploying web and ejb module separately, on their own (no ear involved), on the same instance and using @EJB annotation to inject ejbs into JSF managed-beans works. – Bhesh Gurung Dec 15 '11 at 22:15 
add comment

4 Answers

up vote11down voteaccepted
Officially @Local annotated beans can only be accessed if they're in the same application. A .war deployed separately from an .ear (or other .war or other .jar EJB) is a different application, even when deployed to the same application server instance.
There's thus no guarantee that the code in your .war can call @Local EJB beans that are defined in the .ear.
However, in practice in nearly all application servers this just works.
There's a request for the EJB 3.2 spec to officially support local cross-application calls:http://java.net/jira/browse/EJB_SPEC-22
share|improve this answer
4 
I feel somewhat sad to be the only one who voted on this feature... Everyone - feel free to join and just click 'vote' on this JIRA request ;-) –  Piotr Nowicki Dec 15 '11 at 23:15
 
It might be quite hard to have 100% working cross-application (cross ClassLoader!) calls. Let ClassLoader 1 has class A and ClassLoader 2 has class A (another copy). Passing object A via local interface will cause ClassCastException because there are two copies of the same class. An EAR has its own sometimes isolated ClassLoader. –  Piotr Gwiazda Sep 4 '12 at 20:39
 
Yes, the class loading isolation might be the problem here. It would still work for classes from the JDK and possibly for (interface) classes from the AS (depending on how the AS does modularization of those). Many users will probably not understand this limitation and it might become one of the new puzzlers in Java EE. – Arjan Tijms Sep 4 '12 at 21:37 
add comment
Local interfaces are to be used in communication within the same application. It doesn't necessarily mean JVM.
The point is: even within the same JVM instance, on the same server, two different applications cannotcommunicate using local interfaces (which means local and no-interface views).
If you have a web component (WAR) as well as a business component (EJB-JAR) which is in the same application, the most intuitive and straightforward solution is to package them in one EAR or in one WAR (since Java EE 6).
share|improve this answer
1 
Yes but this is all just theory. In practice you have a big application with multiple WARs (i.e. partner, customer and administration portal application), calling the same EJBs. For deployment/less downtime reasons you would want to package these WARs separately, as many people do. –  bozo May 7 '12 at 9:41
 
Agreed - I also don't like this idea and the cumbersome EAR approach as well, but it's the officially suggested solution. –  Piotr Nowicki May 7 '12 at 10:21
1 
Don't get me started on JEE people. The whole thing is a job security project. We've been using it in complex projects for years, and I must say that we were 10 times more productive in PHP. But nowadays the PHP is "uncool" with various certifications people, and you have to have a certificate to sell toilet paper today, so we all have to suffer bloated bullsh*t that doesn't do anything properly. It reminds me of F-35. ;) –  bozo May 9 '12 at 13:45
add comment

4 comments:

oakleyses said...

louis vuitton handbags, oakley sunglasses, louboutin, longchamp outlet, nike shoes, louis vuitton outlet stores, chanel handbags, burberry outlet, prada outlet, jordan shoes, tiffany and co, michael kors outlet, tory burch outlet, louis vuitton outlet, longchamp handbags, nike free, true religion jeans, michael kors outlet, kate spade outlet, polo ralph lauren outlet, tiffany and co, prada handbags, polo ralph lauren outlet, michael kors outlet, michael kors outlet, longchamp handbags, oakley sunglasses, ray ban sunglasses, kate spade handbags, burberry outlet, louis vuitton outlet, louboutin outlet, louboutin, coach factory outlet, air max, air max, coach outlet, gucci outlet, christian louboutin shoes, michael kors outlet, coach purses, ray ban sunglasses, michael kors outlet, louis vuitton, coach outlet store online, true religion jeans, oakley sunglasses cheap

oakleyses said...

ralph lauren, lululemon, air max, hollister, north face, nike air max, polo lacoste, vanessa bruno, timberland, vans pas cher, louboutin, louis vuitton, oakley pas cher, air max pas cher, nike roshe run, air max, true religion outlet, barbour, sac longchamp, air force, hollister, sac louis vuitton, nike free, polo ralph lauren, nike trainers, louis vuitton uk, nike roshe, sac hermes, longchamp, michael kors, sac burberry, sac guess, mulberry, new balance pas cher, converse pas cher, sac louis vuitton, hogan outlet, nike tn, north face, true religion outlet, ray ban pas cher, michael kors, air jordan, nike blazer, nike free pas cher, michael kors pas cher, abercrombie and fitch, ray ban sunglasses

oakleyses said...

mac cosmetics, mont blanc, marc jacobs, canada goose outlet, nike huarache, vans shoes, soccer jerseys, hollister, giuseppe zanotti, beats by dre, abercrombie and fitch, longchamp, insanity workout, celine handbags, bottega veneta, ghd, nfl jerseys, north face outlet, chi flat iron, ugg boots, birkin bag, ugg australia, canada goose, herve leger, ugg pas cher, rolex watches, valentino shoes, canada goose uk, canada goose, ferragamo shoes, canada goose, ugg boots, uggs outlet, north face jackets, soccer shoes, asics running shoes, new balance shoes, p90x, lululemon outlet, canada goose jackets, mcm handbags, instyler, babyliss pro, ugg, wedding dresses, jimmy choo outlet, reebok outlet, nike roshe run

oakleyses said...

parajumpers, karen millen, air max, converse, pandora charms, moncler, louboutin, moncler, links of london, lancel, juicy couture outlet, oakley, hollister, pandora charms, supra shoes, thomas sabo, canada goose, gucci, wedding dresses, timberland boots, swarovski crystal, air max, coach outlet store online, moncler, ray ban, canada goose, moncler, ugg, louis vuitton, swarovski, hollister, montre homme, moncler, hollister clothing store, ralph lauren, rolex watches, moncler outlet, moncler, iphone 6 cases, baseball bats, juicy couture outlet, toms shoes, vans, pandora jewelry, ugg, converse shoes