| <?xml version="1.0"?> |
| <document> |
| <properties> |
| <title>Using java:comp/env lookups</title> |
| </properties> |
| <body> |
| <section title="Adding ejb-ref in your web.xml"> |
| <p> |
| An example is best for this. Say you had a block like the |
| following in your web.xml file. |
| </p> |
| <PRE> |
| <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> |
| </PRE> |
| </section> |
| <section title="Adding the Ejb in your server.xml"> |
| <p> |
| 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 <Context> section of Tomcat's server.xml file. Here is an example of that: |
| </p> |
| <PRE> |
| <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> |
| </PRE> |
| <p> |
| This would link the name "ejb/hello" to a bean called "Hello" in the OpenEJB container system. |
| </p> |
| <p> |
| For more information see <A HREF="http://www.openejb.org/tomcat-object-factory.html">Leveraging J2EE JNDI Lookups</A> |
| </p> |
| </section> |
| </body> |
| </document> |
| |