• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

@LocalBean and @Remote for the same session bean

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going through Frits notes on EJB 3.1. In page 2-11, there is a code example

@Stateless
@Remote(EchoBeanRemote.class)
@LocalBean
public class EchoBean implements EchoBeanRemote {
}

With the above code, The methods declared in EchoBeanRemote interface would be exposed to remote clients. But, by adding @LocalBean, does this mean that all the public methods of the bean (irrespective of the methods declared in remote interface) are exposed to local clients?

Also for @Local and @LocalBean, The client and the bean implementation should be within the same EAR. Please correct me if I am wrong.

Thanks.
 
Creator of Enthuware JWS+ V6
Posts: 3325
298
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

With the above code, The methods declared in EchoBeanRemote interface would be exposed to remote clients. But, by adding @LocalBean, does this mean that all the public methods of the bean (irrespective of the methods declared in remote interface) are exposed to local clients?


Yes, through the no-interface client view.

Also for @Local and @LocalBean, The client and the bean implementation should be within the same EAR. Please correct me if I am wrong.


Yes, that is correct.

Note however that the definition of a local client (Local view or No-interface view) means that the client is collocated in the same JVM which doesn't necessarily mean that they have to be packaged in the same EAR. However the EJB specifications further specify that access to an enterprise bean through the local client view is only required to be supported for local clients packaged within the same application.
 
Ranch Hand
Posts: 1869
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a good example from Ivan's notes: https://coderanch.com/t/647080/java-EJB-SCBCD/certification/lookup-remote-bean
I forgot to annotation the interface with @Remote, so by default it is @Local.
I package the servlet client in .war ,EJB in .jar and package both .war and .jar in the same .ear, the servlet client can lookup the EJB.
But if the .war and .jar are not in the same .ear or in different .ear files, the servlet client cannot lookup the EJB. It is because the EJB is exposed as a @Local view.
 
Nandhini Sridharan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Himai and Frits
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic