geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Aufdencamp <m...@aufdencamp.com>
Subject RE: Accessing the local interface of an Session EJB from a WAR
Date Tue, 27 Feb 2007 15:00:51 GMT
<BR>
<DIV name="wmMessageComp">Hi Norbert,</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">
I'm no expert here, but just got done working on a similar learning
curve.&nbsp; I believe that local can only be defined if an EAR/application.xml/ geronimo-application.xml
file exist, defining an enterprise application project.&nbsp;&nbsp;I'm using a remote
rather than local session bean and managed to get it to work.&nbsp;Your problem is most
likely all about deployment descripitors and package dependencies.</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">So here goes:</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">
1. web.xml - This should have an &lt;ejb-ref&gt; component.&nbsp; It
should contain a &lt;ejb-ref-name&gt; which serves as the local JNDI lookup suffix.&nbsp;
It will serve as the lookup string for the Context.lookup("java:comp/env/ejb/MfcSessionEJB").&nbsp;&nbsp;It
also serves as the linkage to the &lt;ref-name&gt; in the geronimo-web.xml.&nbsp;
This will factory a MfcSessionEJBHome object for creation of a reference to a MfcSessionEJB.&nbsp;
It should also contain a &lt;ejb-ref-type&gt; along with a &lt;home&gt; and
&lt;remote&gt;, which serves as the link to the EJB definition in the geronimo deployment
descripitor for the webapp (geronimo-web.xml)</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&lt;ejb-ref&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;ejb-ref-name&gt;ejb/MfcSessionEJB&lt;/ejb-ref-name&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;home&gt;gltd.domain.app.interfaces.MfcSessionEJBHome&lt;/home&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;remote&gt;gltd.domain.app.interfaces.MfcSessionEJB&lt;/remote&gt;</DIV>
<DIV name="wmMessageComp">&lt;/ejb-ref&gt;<BR>...</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">Servlet/JSP code snippet:</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">Context ctx = new InitialContext();</DIV>
<DIV name="wmMessageComp">MfcSessionEJBHome mfcSessionHome = (MfcSessionEJBHome) ctx.lookup("java:comp/env/ejb/MfcSessionEJB");</DIV>
<DIV name="wmMessageComp">MfcSessionEJB mfcSession = mfcSessionHome.create();</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">2. geronimo-web.xml - This deployment descriptor needs two
components.&nbsp; It needs an &lt;ejb-ref&gt; that&nbsp;matches the web.xml
&lt;ejb-ref-name&gt;&nbsp; and defines the deployed EJB module as a pattern(module
group/artifact/version/type).&nbsp; This serves as the linkage between the web.xml and
the container for name service purposes.&nbsp; Second it needs to define the EJB module
as a dependency for the webapp with a &lt;dependencies&gt;&lt;dependency&gt;
in the &lt;environment&gt; section.&nbsp; This allows access for the webapp Classloader
to the EJB module.&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&lt;environment&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;moduleId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; ...</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;/moduleId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;dependencies&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;dependency&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;groupId&gt;default&lt;/groupId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;artifactId&gt;MfcSessionEJB&lt;/artifactId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;version&gt;1.0&lt;/version&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;type&gt;car&lt;/type&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/dependency&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dependencies&gt;</DIV>
<DIV name="wmMessageComp">&lt;/environment&gt;</DIV>
<DIV name="wmMessageComp">&lt;ejb-ref&gt;</DIV>
<DIV name="wmMessageComp">
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- geronimo-web.xml.&lt;ref-name&gt;
==
web.xml.&lt;ejb-ref-name&gt; --&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;ref-name&gt;ejb/MfcSessionEJB&lt;/ref-name&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;pattern&gt;</DIV>
<DIV name="wmMessageComp">
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;groupId&gt;default&lt;/groupId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;artifactId&gt;MfcSessionEJB&lt;/artifactId&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;version&gt;1.0&lt;/version&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;type&gt;car&lt;/type&gt;</DIV>&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/pattern&gt;</DIV>
<DIV name="wmMessageComp">&lt;/ejb-ref&gt;<BR></DIV>
<DIV name="wmMessageComp">
3. ejb-jar.xml&nbsp; - Needs a &lt;enterprise-bean&gt;&lt;session&gt;
entry which can be generated by XDoclet.&nbsp; The &lt;ejb-name&gt; here needs
to match the &lt;ejb-name&gt; defined in the openejb-jar.xml.&nbsp; The webapp
appaerntly also uses the &lt;home&gt; and &lt;remote&gt; values here to validate
the EJB signature at webapp deployment time.</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&lt;enterprise-beans&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;session&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;description&gt;My MFC Session EJB&lt;/description&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;display-name&gt;MFC Session EJB&lt;/display-name&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&lt;ejb-name&gt;MfcSessionEJB&lt;/ejb-name&gt;
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;home&gt;gltd.domain.app.interfaces.MfcSessionEJBHome&lt;/home&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;remote&gt;gltd.domain.app.interfaces.MfcSessionEJB&lt;/remote&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;ejb-class&gt;gtld.domain.app.ejb.MfcSessionEJB&lt;/ejb-class&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;session-type&gt;Stateless&lt;/session-type&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;transaction-type&gt;Container&lt;/transaction-type&gt;</DIV>&nbsp;&nbsp;&nbsp;
&lt;/session&gt;</DIV>
<DIV name="wmMessageComp">
<DIV name="wmMessageComp">&lt;/enterprise-beans&gt;</DIV></DIV>
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">4. openejb-jar.xml - This needs a &lt;enterprise-beans&gt;&lt;session&gt;
component.&nbsp; The &lt;ejb-name&gt; needs to match the ej-jar.xml &lt;ejb-name&gt;
as previously stated.&nbsp; The &lt;jndi-name&gt; does not appear to be used for
referenc within the container but would be required for a stand alone app call to the EJB.</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&lt;enterprise-beans&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp; &lt;session&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;ejb-name&gt;MfcSessionEJB&lt;/ejb-name&gt; </DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;jndi-name&gt;ejb/MfcSessionEJB&lt;/jndi-name&gt;</DIV>
<DIV name="wmMessageComp">&nbsp;&nbsp;&nbsp; &lt;/session&gt;</DIV>
<DIV name="wmMessageComp">
<DIV name="wmMessageComp">&lt;/enterprise-beans&gt;</DIV></DIV>
<DIV name="wmMessageComp">...</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV></DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">
5. No additional libraries needed to be&nbsp;deployed&nbsp;with the WAR
to make the EJB lookup and method invocations.</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">
Hope this helps.&nbsp; I spent a week and a half figuring this out on my
own.&nbsp; If you'ld like to try calling the EJB from a app client,&nbsp; I can help
with that as well.</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">Mark Aufdencamp</DIV>
<DIV name="wmMessageComp"><A href="mailto:Mark@Aufdencamp.com">Mark@Aufdencamp.com</A></DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<DIV name="wmMessageComp">&nbsp;</DIV>
<BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" name="wmMessageComp">--------
Original Message --------<BR>
Subject: Accessing the local interface of an Session EJB from a
WAR<BR>From: "Norbert Rieger" &lt;nrieger@lplusr.de&gt;<BR>Date: Tue,
February 27, 2007 4:08 am<BR>To: &lt;user@geronimo.apache.org&gt;<BR><BR>Hello,<BR><BR>
I try to connect from my web application to an existing Session
EJB<BR>(MfcSession) thru it's local interface.<BR>Both, the WAR and the EJB, are
running within the same geronimo<BR>
installation. When installing the web app I get the following
message:<BR><BR>
Deployer operation failed: Could not find an EJB for reference
MfcSession to<BR>a local session bean that has the home interface<BR>de.lplusr.module.mfc.ejb.MfcSessionLocalHome
and the local interface<BR>de.lplusr.module.mfc.ejb.MfcSessionLocal<BR>
org.apache.geronimo.common.UnresolvedEJBRefException: Could not find an
EJB<BR>
for reference MfcSession to a local session bean that has the home
interface<BR>de.lplusr.module.mfc.ejb.MfcSessionLocalHome and the local interface<BR>de.lplusr.module.mfc.ejb.MfcSessionLocal<BR><BR>
How do I connect to an EJB thru it's local interface, what's wrong with
my<BR>configuration ?<BR><BR>Any help or advice is appreciated, thanks a
lot in advance.<BR><BR>Norbert<BR><BR><BR>This is my configuration:<BR><BR>Geronimo
1.1.1<BR>JDK 1.5.0_10<BR>Windows XP Prof<BR><BR><BR>web.xml:<BR><BR>&lt;ejb-local-ref&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp;&lt;ejb-ref-name&gt;MfcSession&lt;/ejb-ref-name&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp;&lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp;&lt;local-home&gt;de.lplusr.module.mfc.ejb.MfcSessionLocalHome&lt;/local-home<BR>&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp;&lt;local&gt;de.lplusr.module.mfc.ejb.MfcSessionLocal&lt;/local&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp;&lt;ejb-link&gt;MfcSession&lt;/ejb-link&gt;<BR>&lt;/ejb-local-ref&gt;<BR><BR>geronimo-web.xml:<BR><BR>&lt;?xml
version="1.0" encoding="UTF-8"?&gt;<BR><BR>&lt;web-app<BR>xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"<BR>&nbsp;
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"<BR>&nbsp; xmlns:naming="http://geronimo.apa
 che.org/xml/ns/naming-1.1"<BR>&nbsp; xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"&gt;<BR>&lt;environment
xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1"&gt;<BR>&nbsp; &lt;moduleId&gt;<BR>&nbsp;
&nbsp; &lt;groupId&gt;lplusr&lt;/groupId&gt;<BR>&nbsp; &nbsp;
&lt;artifactId&gt;sys&lt;/artifactId&gt;<BR>&nbsp; &nbsp; &lt;version&gt;1.0&lt;/version&gt;<BR>&nbsp;
&lt;/moduleId&gt;<BR>&nbsp; &lt;dependencies&gt;<BR>&nbsp;
&lt;dependency&gt;<BR>&nbsp; &lt;groupId&gt;ejb&lt;/groupId&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;artifactId&gt;mfc-ejb&lt;/artifactId&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;version&gt;1.0&lt;/version&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;type&gt;jar&lt;/type&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/dependency&gt;<BR>&nbsp;
&lt;/dependencies&gt;<BR>&lt;/environment&gt;<BR>&lt;context-root&gt;/sys&lt;/context-root&gt;<BR>&lt
 ;ejb-local-ref&gt;<BR>&lt;ref-name&gt;MfcSession&lt;/ref-name&gt;<BR>&lt;ejb-link&gt;MfcSession&lt;/ejb-link&gt;<BR>&lt;/ejb-local-ref&gt;<BR>&lt;/web-app&gt;<BR><BR><BR>The
EJB descriptor is:<BR><BR>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<BR><BR>&lt;!DOCTYPE
ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise<BR>JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"&gt;<BR><BR>&lt;ejb-jar
id="ejb-jar_1"&gt;<BR><BR>
&nbsp; &lt;description&gt;&lt;![CDATA[mfc-ejb-1.0 generated by eclipse
wtp xdoclet<BR>extension.]]&gt;&lt;/description&gt;<BR>&nbsp;
&lt;display-name&gt;mfc-ejb-1.0&lt;/display-name&gt;<BR><BR>&nbsp;
&lt;enterprise-beans&gt;<BR><BR>&nbsp; &nbsp; &nbsp;&lt;!--
Session Beans --&gt;<BR>&nbsp; &nbsp; &nbsp;&lt;session id="Session_MfcSession"&gt;<BR>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;description&gt;&lt;![CDATA[An
EJB for
remote access of<BR>MFC]]&gt;&lt;/description&gt;<BR>&nbsp; &nbsp;
&nbsp; &nbsp; &lt;display-name&gt;MfcSession&lt;/display-name&gt;<BR><BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;ejb-name&gt;MfcSession&lt;/ejb-name&gt;<BR><BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;home&gt;de.lplusr.module.mfc.ejb.MfcSessionHome&lt;/home&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;remote&gt;de.lplusr.module.mfc.ejb.MfcSession&lt;/remote&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;local-home&gt;de.lplusr.module.mfc.ejb.MfcSessionLocalHome&lt;/local-hom<BR>e&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;local&gt;de.lplusr.module.mfc.ejb.MfcSessionLocal&lt;/local&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;ejb-class&gt;de.lplusr.module.mfc.ejb.MfcSessionSession&lt;/ejb-class&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;session-type&gt;Stateful&lt;/session-type&gt;<BR>&nbsp;
&nbsp; &nbsp; &nbsp; &lt;transaction-type&gt;Container&lt;/transaction-type&gt;<BR><BR>&nbsp;
&nbsp; &nbsp;&lt;/session&gt;<BR><BR>&lt;/ejb-jar&gt;
</BLOCKQUOTE>


Mime
View raw message