Este contenido no está disponible en el idioma seleccionado.

Chapter 34. EJB Integration


To integrate with Enterprise JavaBeans (EJB), you must first modify your EJB's published interfaces. Currently, RESTEasy only has simple portable integration with EJBs, so you must manually configure your RESTEasy WAR.
To make an EJB a JAX-RS resource, annotate a stateless session bean's @Remote or @Local interface with JAX-RS annotations, as follows:
@Local
@Path("/Library")
public interface Library {
   
   @GET
   @Path("/books/{isbn}")
   public String getBook(@PathParam("isbn") String isbn);
}

@Stateless
public class LibraryBean implements Library {

...

}
Copy to Clipboard Toggle word wrap
Next, in RESTEasy's web.xml, manually register the EJB with RESTEasy by 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>

   <listener>
      <listener-class>org.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
   </listener>

   <servlet>
      <servlet-name>Resteasy</servlet-name>
      <servlet-class>org.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
   </servlet>

   <servlet-mapping>
      <servlet-name>Resteasy</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>

</web-app>
Copy to Clipboard Toggle word wrap
At present, this is the only portable integration method for EJBs. Future versions of RESTEasy will be more tightly integrated with JBoss AS, so manual registrations and modifications to web.xml will be unnecessary.
If you are using RESTEasy with an EAR and EJBs, the following structure is helpful:
my-ear.ear
|------myejb.jar
|------resteasy-jaxrs.war
       |
       ----WEB-INF/web.xml
       ----WEB-INF/lib (nothing)
|------lib/
       |
       ----All Resteasy jar files
Copy to Clipboard Toggle word wrap
Remove all libraries from WEB-INF/lib and place them in a common EAR library, or place the RESTEasy JAR dependencies in your application server's system classpath (that is, in JBoss AS, place them in server/default/lib).
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat