Jersey, Glassfish, and EJBs as root resources
By sandoz on Dec 02, 2008
Jersey supports EJB 3.0 beans as root resources as follows:
- Annotate a local or remote interface with @Path and annotate methods as appropriate; and
- Ensure that the local or remote interface in 1) is registered by file/directory or package scanning.
The registration mechanism in 2) is no different for registering non-EJBs. The caveat: it currently only works with Glassfish, which supports JNDI lookup of an EJB reference using the fulling qualified class name of the local or remote interface.
The JSR 311 expert group is currently considering approaches to integrate JAX-RS with EJB 3.1, which should present some nice improvements, namely EJBs bundled in the war and EJBs with no interfaces. I have high hopes we can retain the current ease of use registration aspects with JAX-RS as presented here and then it should be really simple to use EJBs as POJOs in the web tier directly serving HTTP requests.