jBoss EJB
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Servlets and Filters
Portlets
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

IDE's
Scottit
Groovy
PHP
Code Libraries
EJB Servers
JMS
JCA Resources
JMX
SSL Accelerators

jBoss
Inprise
JOnAS
Weblogic
Orion
EJB Servers
EJB Servers
Inprise

From Dave Dribin:

To have a Resin web application use jBoss, do the following:

  1. Copy "ejb.jar", "jboss-client.jar", and "jnp-client.jar" from $JBOSS_HOME/client into WEB-INF/lib.
  2. Copy the EJB jar file that you put in $JBOSS_HOME/deploy into WEB-INF/lib.
  3. Put the following <web-app> into resin.conf:

    <web-app id='/web-app-path' app-dir='/real/path/of/web-app'>
      <jndi-link>
        <jndi-name>java:comp/env/ejb</jndi-name>
        <jndi-factory>org.jnp.interfaces.NamingContextFactory</jndi-factory>
        <init-param java.naming.provider.url="localhost:1099"/>
      </jndi-link>
    </web-app>
    
    Of course change the JNDI URL if you're running jBoss on a different machine.

  4. Make sure you map all of your EJBs to the "ejb/" JNDI context. For example, I have this in my jboss.xml:

    <enterprise-beans>
      <entity>
        <ejb-name>UserBean</ejb-name>
        <jndi-name>ejb/UserHome</jndi-name>
      </entity>
    
      .... other beans ....
    
    </enterprise-beans>
    
    This way you can lookup all the Home interfaces in the "java:comp/env/ejb/" context.

I've attached a simple JSP that shows how to access the User EJB.

And don't forget that if you re-deploy your beans to jBoss, you should copy over the jar file into WEB-INF and restart Resin.

Hope that helps!

-Dave

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>EJB Test</title>
  </head>

  <body bgcolor="#FFFFFF">
    <%@ page import='javax.naming.*' %>
    <%@ page import='ejbeans.*' %>
    <%@ page import='javax.rmi.*' %>
    <h1 align=center>EJB Test</h1>

    <%
            // Get a naming context
            InitialContext jndiContext;
            Object ref;

            // Get a reference to a UserHome Bean
            jndiContext = new InitialContext();
            ref         = jndiContext.lookup("java:comp/env/ejb/UserHome");

            int         userPK;

            UserHome    userHome;
            User        user;

            userHome = (UserHome)
                PortableRemoteObject.narrow (ref, UserHome.class);

            userPK  = Integer.parseInt(request.getParameter("pk"));
            user    = userHome.findByPrimaryKey(new UserPK(userPK));
    %>

    <table border="3" width="100%">
        <tr>
          <th> ID </th>
          <th> First Name </th>
          <th> Last Name </th>
        </tr>

        <tr>
          <th> <%= user.getId() %> </th>
          <th> <%= user.getFirstName() %> </th>

          <th> <%= user.getLastName() %> </th>
        </tr>

    </table>

  </body>
</html>


EJB Servers
EJB Servers
Inprise
Copyright © 1998-2005 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.