JBoss.orgCommunity Documentation

Chapter 47. Jakarta Enterprise Beans Integration

RESTEasy currently only has simple integration with Jakarta Enterprise Beans. To make a bean a Jakarta RESTful Web Services resource, an SLSB's @Remote or @Local interface must be annotated with Jakarta RESTful Web Services annotations. Also the application's beans must be configured in web.xml.


@Local
@Path("/Library")
public interface Library {
   
   @GET
   @Path("/books/{isbn}")
   public String getBook(@PathParam("isbn") String isbn);
}

@Stateless
public class LibraryBean implements Library {

...

}

Next, in RESTEasy's web.xml file manually register the bean with RESTEasy using the resteasy.jndi.resources <context-param>


<web-app>
   <display-name>Archetype Created Web Application</display-name>
   <context-param>
      <param-name>resteasy.jndi.resources</param-name>
      <param-value>LibraryBean/local</param-value>
   </context-param>

   ...
</web-app>

This is the only portable way RESTEasy offers Jakarta Enterprise Beans integration. Future versions of RESTEasy will have tighter integration with Wildfly, thus eliminating manual registrations or modifications to web.xml.

If you're using RESTEasy with an EAR and Jakarta Enterprise Beans, a good structure to have is:


my-ear.ear
|------myejb.jar
|------resteasy-jaxrs.war
       |
       ----WEB-INF/web.xml
       ----WEB-INF/lib (nothing)
|------lib/
       |
       ----All RESTEasy jar files

From the distribution, remove all libraries from WEB-INF/lib and place them in a common EAR lib or place the RESTEasy jar dependencies in the application server's system classpath.