<title>Resin using JOnAS EJB</title>

From Pedro Costa:

<p/>To use Resin as an EJB client with JOnAS or Enhydra Enterprise follow these steps:

<ol>
<li>Under JOnAS or Enhydra do nothing

<li>Copy JEREMIE_jonas.jar (RMI_jonas.jar if you are using rmi and not
jeremie) into WEB-INF/lib or resin1.2/lib.

<p>If you are using JOnAS on the same machine as Resin you can do the same
by adding the following line to your app on resin.conf 
(assuming JOnAS is installed on \JONAS)

<example>
&lt;classpath id='/JONAS/lib/JEREMIE_jonas.jar'/>
</example>

<li>Copy the EJB jar's file containing your beans to WEB-INF/lib
If you are using JOnAS on the same machine as Resin you can do the same
by adding the following line to your app on resin.conf 
(assuming JOnAS is installed on \JONAS and your beans are on a dir called \JONAS\mybeans)

<example>
&lt;classpath id='/JONAS/mybeans' source='/JONAS/mybeans' compile='false'/>
</example>
        
<li>In resin.conf add these lines to your app (assuming you are using jeremie):

<example>
&lt;jndi-link>
  &lt;jndi-name>java:comp/env/ejb&lt;/jndi-name>
  &lt;jndi-factory>
    org.objectweb.jeremie.libs.services.registry.jndi.JRMIInitialContextFactory
  &lt;/jndi-factory>
  &lt;init-param java.naming.provider.url="jrmi://YOUR_HOST:12340"/>
  &lt;init-param java.naming.factory.url.pkgs="org.objectweb.jonas.naming"/>
&lt;/jndi-link>
</example>

<li>Don't forget to change YOUR_HOST to your hostname...
</ol>

<example title="Sample JSP showing how to access your beans">
&lt;!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
&lt;%@ page language="java"%>
&lt;%@ page import="javax.naming.InitialContext" %>
&lt;%@ page import="javax.naming.Context" %>
&lt;%@ page import="javax.rmi.PortableRemoteObject" %>
&lt;%@ page import="YOUR_BEANS_PACKAGE.*" %>
&lt;html>
&lt;head>
&lt;title>Test&lt;/title>
&lt;/head>
&lt;body>
&lt;%
  Context initialContext = new InitialContext();
  Object ref = initialContext.lookup("java:comp/env/ejb/ExpHome");
  ExpHome home = (ExpHome) PortableRemoteObject.narrow(ref, ExpHome.class);
  Exp t1 = home.create(); 
%>
dummy result value = &lt;%=t1.dummyMethod()%>
&lt;%
  t1.remove();    
%>
&lt;/body>
&lt;/html>
</example>
