|  | OpenEJBIndexJNDIEJBClassInvoke |
Using java:comp/env lookups
Adding ejb-ref in your web.xml An example is best for this. Say you had a block like the following in your web.xml file.
    <ejb-ref>
        <description>
            EJB Reference to the bean deployed to OpenEJB
        </description>
        <ejb-ref-name>ejb/hello</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.acme.HelloHome</home>
        <remote>org.acme.Hello</remote>
    </ejb-ref>
Adding the Ejb in your server.xml To make this ejb refence usable in code by your Servlet or JSP, you need to tell Tomcat how to link that to an actual EJB deployed into OpenEJB. This is done in the webapps section of Tomcat's server.xml file. Here is an example of that:
    <Server>
        ...
        <Context path=...>
            ...
            <Ejb name="ejb/hello"
                 type="Session"
                 home="org.acme.HelloHome"
                 remote="org.acme.Hello"/>
            <ResourceParams name="ejb/hello">
                <parameter>
                    <name>factory</name>
                    <value>org.openejb.client.TomcatEjbFactory</value>
                </parameter>
                <parameter>
                    <name>openejb.naming.factory.initial</name>
                    <value>org.openejb.client.LocalInitialContextFactory</value>
                </parameter>
                <parameter>
                    <name>openejb.ejb-link</name>
                    <value>Hello</value>
                </parameter>
            </ResourceParams>
        </Context>
        ...
    </Server>
This would link the name "ejb/hello" to a bean called "Hello" in the OpenEJB container system. For more information see Leveraging J2EE JNDI Lookups |