geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbert Rieger" <nrie...@lplusr.de>
Subject AW: Accessing the local interface of an Session EJB from a WAR
Date Tue, 27 Feb 2007 15:23:54 GMT
Hi Mark,

thanks a lot for your detailed explanations.

1. I thought <ejb-ref> is used for accessing the remote interface, for the
local interface <ejb-local-ref> with children <local> and <local-home> must
be used. Isn't this correct ?

I've neither an openejb-jar.xml nor an ejb-jar.xml in my war file, only
web.xml and geronimo-web.xml. If it's necessary the have them in the web
app, I'll added them....

regards,

Norbert
  -----Ursprungliche Nachricht-----
  Von: Mark Aufdencamp [mailto:mark@aufdencamp.com]
  Gesendet: Dienstag, 27. Februar 2007 16:01
  An: user@geronimo.apache.org
  Betreff: RE: Accessing the local interface of an Session EJB from a WAR




  Hi Norbert,

  I'm no expert here, but just got done working on a similar learning curve.
I believe that local can only be defined if an EAR/application.xml/
geronimo-application.xml file exist, defining an enterprise application
project.  I'm using a remote rather than local session bean and managed to
get it to work. Your problem is most likely all about deployment
descripitors and package dependencies.

  So here goes:

  1. web.xml - This should have an <ejb-ref> component.  It should contain a
<ejb-ref-name> which serves as the local JNDI lookup suffix.  It will serve
as the lookup string for the
Context.lookup("java:comp/env/ejb/MfcSessionEJB").  It also serves as the
linkage to the <ref-name> in the geronimo-web.xml.  This will factory a
MfcSessionEJBHome object for creation of a reference to a MfcSessionEJB.  It
should also contain a <ejb-ref-type> along with a <home> and <remote>, which
serves as the link to the EJB definition in the geronimo deployment
descripitor for the webapp (geronimo-web.xml)


  ...
  <ejb-ref>
       <ejb-ref-name>ejb/MfcSessionEJB</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <home>gltd.domain.app.interfaces.MfcSessionEJBHome</home>
       <remote>gltd.domain.app.interfaces.MfcSessionEJB</remote>
  </ejb-ref>
  ...


  Servlet/JSP code snippet:

  Context ctx = new InitialContext();
  MfcSessionEJBHome mfcSessionHome = (MfcSessionEJBHome)
ctx.lookup("java:comp/env/ejb/MfcSessionEJB");
  MfcSessionEJB mfcSession = mfcSessionHome.create();


  2. geronimo-web.xml - This deployment descriptor needs two components.  It
needs an <ejb-ref> that matches the web.xml <ejb-ref-name>  and defines the
deployed EJB module as a pattern(module group/artifact/version/type).  This
serves as the linkage between the web.xml and the container for name service
purposes.  Second it needs to define the EJB module as a dependency for the
webapp with a <dependencies><dependency> in the <environment> section. 
This
allows access for the webapp Classloader to the EJB module.

  ...
  <environment>
       <moduleId>
       ...
       </moduleId>
       <dependencies>
            <dependency>
                 <groupId>default</groupId>
                 <artifactId>MfcSessionEJB</artifactId>
                 <version>1.0</version>
                 <type>car</type>
            </dependency>
       </dependencies>
  </environment>
  <ejb-ref>
       <!-- geronimo-web.xml.<ref-name> == web.xml.<ejb-ref-name> -->
       <ref-name>ejb/MfcSessionEJB</ref-name>
       <pattern>
            <groupId>default</groupId>
            <artifactId>MfcSessionEJB</artifactId>
            <version>1.0</version>
            <type>car</type>
       </pattern>
  </ejb-ref>

  3. ejb-jar.xml  - Needs a <enterprise-bean><session> entry which can be
generated by XDoclet.  The <ejb-name> here needs to match the <ejb-name>
defined in the openejb-jar.xml.  The webapp appaerntly also uses the <home>
and <remote> values here to validate the EJB signature at webapp deployment
time.

  ...
  <enterprise-beans>
       <session>
            <description>My MFC Session EJB</description>
            <display-name>MFC Session EJB</display-name>
            <ejb-name>MfcSessionEJB</ejb-name>
            <home>gltd.domain.app.interfaces.MfcSessionEJBHome</home>
            <remote>gltd.domain.app.interfaces.MfcSessionEJB</remote>
            <ejb-class>gtld.domain.app.ejb.MfcSessionEJB</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
      </session>
  </enterprise-beans>
  ...


  4. openejb-jar.xml - This needs a <enterprise-beans><session> component.
The <ejb-name> needs to match the ej-jar.xml <ejb-name> as previously
stated.  The <jndi-name> does not appear to be used for referenc within the
container but would be required for a stand alone app call to the EJB.

  ...
  <enterprise-beans>
       <session>
            <ejb-name>MfcSessionEJB</ejb-name>
            <jndi-name>ejb/MfcSessionEJB</jndi-name>
      </session>
  </enterprise-beans>
  ...


  5. No additional libraries needed to be deployed with the WAR to make the
EJB lookup and method invocations.


  Hope this helps.  I spent a week and a half figuring this out on my own.
If you'ld like to try calling the EJB from a app client,  I can help with
that as well.

  Mark Aufdencamp
  Mark@Aufdencamp.com



    -------- Original Message --------
    Subject: Accessing the local interface of an Session EJB from a WAR
    From: "Norbert Rieger" <nrieger@lplusr.de>
    Date: Tue, February 27, 2007 4:08 am
    To: <user@geronimo.apache.org>

    Hello,

    I try to connect from my web application to an existing Session EJB
    (MfcSession) thru it's local interface.
    Both, the WAR and the EJB, are running within the same geronimo
    installation. When installing the web app I get the following message:

    Deployer operation failed: Could not find an EJB for reference
MfcSession to
    a local session bean that has the home interface
    de.lplusr.module.mfc.ejb.MfcSessionLocalHome and the local interface
    de.lplusr.module.mfc.ejb.MfcSessionLocal
    org.apache.geronimo.common.UnresolvedEJBRefException: Could not find an
EJB
    for reference MfcSession to a local session bean that has the home
interface
    de.lplusr.module.mfc.ejb.MfcSessionLocalHome and the local interface
    de.lplusr.module.mfc.ejb.MfcSessionLocal

    How do I connect to an EJB thru it's local interface, what's wrong with
my
    configuration ?

    Any help or advice is appreciated, thanks a lot in advance.

    Norbert


    This is my configuration:

    Geronimo 1.1.1
    JDK 1.5.0_10
    Windows XP Prof


    web.xml:

    <ejb-local-ref>
           <ejb-ref-name>MfcSession</ejb-ref-name>
           <ejb-ref-type>Session</ejb-ref-type>
           <local-home>de.lplusr.module.mfc.ejb.MfcSessionLocalHome</local-h
ome
    >
           <local>de.lplusr.module.mfc.ejb.MfcSessionLocal</local>
           <ejb-link>MfcSession</ejb-link>
    </ejb-local-ref>

    geronimo-web.xml:

    <?xml version="1.0" encoding="UTF-8"?>

    <web-app
    xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
      xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
      xmlns:naming="http://geronimo.apa che.org/xml/ns/naming-1.1"
      xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1">
    <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
      <moduleId>
        <groupId>lplusr</groupId>
        <artifactId>sys</artifactId>
        <version>1.0</version>
      </moduleId>
      <dependencies>
      <dependency>
      <groupId>ejb</groupId>
                     <artifactId>mfc-ejb</artifactId>
                     <version>1.0</version>
                     <type>jar</type>
               </dependency>
      </dependencies>
    </environment>
    <context-root>/sys</context-root>
    < ;ejb-local-ref>
    <ref-name>MfcSession</ref-name>
    <ejb-link>MfcSession</ejb-link>
    </ejb-local-ref>
    </web-app>


    The EJB descriptor is:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
    JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

    <ejb-jar id="ejb-jar_1">

      <description><![CDATA[mfc-ejb-1.0 generated by eclipse wtp xdoclet
    extension.]]></description>
      <display-name>mfc-ejb-1.0</display-name>

      <enterprise-beans>

         <!-- Session Beans -->
         <session id="Session_MfcSession">
            <description><![CDATA[An EJB for remote access of
    MFC]]></description>
            <display-name>MfcSession</display-name>

            <ejb-name>MfcSession</ejb-name>

            <home>de.lplusr.module.mfc.ejb.MfcSessionHome</home>
            <remote>de.lplusr.module.mfc.ejb.MfcSession</remote>
            <local-home>de.lplusr.module.mfc.ejb.MfcSessionLocalHome</local-
hom
    e>
            <local>de.lplusr.module.mfc.ejb.MfcSessionLocal</local>
            <ejb-class>de.lplusr.module.mfc.ejb.MfcSessionSession</ejb-class
>
            <session-type>Stateful</session-type>
            <transaction-type>Container</transaction-type>

         </session>

    </ejb-jar>

Mime
View raw message