aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes EJB JAX-RS service endpoint deployed in a servlet container? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "EJB JAX-RS service endpoint deployed in a servlet container?" Watch "EJB JAX-RS service endpoint deployed in a servlet container?" New topic
Author

EJB JAX-RS service endpoint deployed in a servlet container?

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 758
According to Jersey tutorial chapter 4:

Please note that Jersey currently does not support deployment of JAX-RS applications packaged as standalone EJB modules (ejb-jars). To use EJBs as JAX-RS resources, the EJBs need to be packaged either directly in a WAR or in an EAR that contains at least one WAR. This is to ensure Servlet container initialization that is necessary for bootstrapping of the Jersey runtime.


Does that mean EJB based JAX-RS service is only deployed in a servlet container or web container instead of EJB container?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1679
    
  25

Does that mean EJB based JAX-RS service is only deployed in a servlet container or web container instead of EJB container?

No, this means that you can only use an EJB as a JAX-RS root resource if it is deployed in a package that also contains a web-module.

There are a couple of options:
1) .war (with an EJB)
2) .ear including an .war (with an EJB)
3) .ear including an .war and an .jar (with an EJB)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41906
    
  63
1) .war (with an EJB)

I'm intrigued - since a servlet container doesn't generally host EJBs, would this be sort of a remote invocation, where the actual EJB runs on a different (JEE) server? Sort of like the split between Home and Remote interface in the old days?


Ping & DNS - my free Android networking tools app
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 758
I think the scenario is like this:
1. package a EJB JAX-RS resource class, which is annotated as @Stateless and @WebService and its dependent classes in .war (consisting of WEB-INF/classes and WEB-INF/lib)
2. deploy a EJB JAX-RS resource class in the EJB container.
3. An application like a JSP or a servlet may locally call the EJB in the EJB container. This application and the EJB are hosted in the same application server, for example, GlassFish.
4. A remote client may remotely call the EJB as it is exposed as a web service.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1679
    
  25

Ulf Dittmer wrote:
1) .war (with an EJB)

I'm intrigued - since a servlet container doesn't generally host EJBs, would this be sort of a remote invocation, where the actual EJB runs on a different (JEE) server? Sort of like the split between Home and Remote interface in the old days?

No, it is actually a local invocation. (this requires the EJB-container and Web-container to run in the same JVM)

Indeed the EJB is running in the EJB-container and the Servlet in its Web-container. From the EE6 specs: "In a Java EE product that includes both an EJB container and a web container, both containers are required to support access to local enterprise beans.")

However the EJB packaged inside a .war is not considered an independent EE-module (i.e. they share the same namespace)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41906
    
  63
I see, so there is actually a local EJB container. Thanks for the clarification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB JAX-RS service endpoint deployed in a servlet container?