This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Why @LocalBean is needed to deploy a EJB ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Why @LocalBean is needed to deploy a EJB ?" Watch "Why @LocalBean is needed to deploy a EJB ?" New topic
Author

Why @LocalBean is needed to deploy a EJB ?

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 721
In NetBean, I have a web application called RoleBasedEJB.
I have a class like this :






Client side:


When the @LocalBean is commented out in the resource root class, Glassfish gives me this error when the client tried to access the resource using credentials john/secret.



Why @LocalBean is important in this case?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1628
    
  23

An EJB with a remote view is not required to be supported as a JAX-RS resource. I am not sure what kind of annotation you have on your StudentService (@Remote maybe?).

Adding the @LocalBean makes the EJB have a local view and that has to be supported by JAX-RS.

Regards,
Frits
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 721
Thanks for your reply.
Before, the StudentService interface did not have any annotation. Now, I put @Remote in this:


The implementation resource root class, StudentServiceImpl has @LocalBean, @Stateless and @DeclaredRoles.

It works the same after I put @Remote in the StudentService interface.

Does it mean all JAX-RS resource root class must be annotated with @LocalBean if it is deployed as @Stateless or @Singleton?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1628
    
  23

Yes, or put @Local in the StudentService interface.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why @LocalBean is needed to deploy a EJB ?
 
Similar Threads
Strange problem - works on maven glassfish but not on Tomcat
Jersey Hibernate Problem
Jersey Response issue driving me batty!
Web Service For Optical Character Recognition
REST Web Services using jersey in Apache Tomcat Server throwing ConnectionException