Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Foreman
Posts: 1907
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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)
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Himai Minh
Ranch Foreman
Posts: 1907
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, so there is actually a local EJB container. Thanks for the clarification.
 
Oh. Hi guys! Look at this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic