users@glassfish.java.net

Re: JAX-RS in GF 2.1 and EJB injection?

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Tue, 20 Apr 2010 14:33:52 +0200

2010/4/20 <glassfish_at_javadesktop.org>:
> Hi Paul,
> thanks for your response.
> Ok as it is necessary for me that my REST Service implementation will work on JEE5 and also JEE6 I will do my implementation without JAX-RS :(  and use my Servlet implementation developed before starting my experiment with JEE6 ;-)

If you want to be JEE5 compatible, define one WAR and one EJB inside
EAR and use JAX-RS in WAR project (not in EJB like you wanted),
referencing EJBs from within your JAX-RS classes. This will suck a
little, as you will have to do write one class for JAX-RS view, one
local interface to access your EJB, like this:
app-core-api.jar -> where are EJB local interfaces and other common stuff,
app-core-ejb.jar -> the EJB module - implementation of your core API,
app-web.war -> the web module, the JAX-RS access to your application.

However it is exactly the same situation as when referencing EJBs from
within servlets, so JAX-RS or plain servlets - accessing EJBs in JEE5
can happen only through interfaces.

In JEE6 you can merge app-core-ejb.jar with app-web.war and there is
no need for app-core-api.jar in that case.