<chapter id="RESTEasy_Enterprise_Bean_Integration">
<title>&ENTERPRISE-BEANS; Integration</title>

<para>
RESTEasy currently only has simple integration with &ENTERPRISE-BEANS;.  To make a bean a &REST-API;
    resource, an SLSB's @Remote or @Local interface must be annotated with &REST-API; annotations.
    Also the application's beans must be configured in web.xml.
</para>
<para>

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

@Stateless
public class LibraryBean implements Library {

...

}
</programlisting>
</para>
<para>

</para>
<para>


</para>
<para>

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

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

   ...
&lt;/web-app&gt;
</programlisting>
</para>
<para>

This is the only portable way RESTEasy offers &ENTERPRISE-BEANS; integration.  Future versions of RESTEasy
    will have tighter integration
    with Wildfly, thus eliminating manual registrations or modifications to web.xml.
</para>
<para>

</para>
<para>


</para>
<para>

If you're using RESTEasy with an EAR and &ENTERPRISE-BEANS;, a good structure to have is:
</para>
<para>

<programlisting>
my-ear.ear
|------myejb.jar
|------resteasy-jaxrs.war
       |
       ----WEB-INF/web.xml
       ----WEB-INF/lib (nothing)
|------lib/
       |
       ----All RESTEasy jar files
</programlisting>
</para>
<para>
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.
</para>

</chapter>
