geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabian Dankof" <fab...@dankof.net>
Subject RE: References between Webapp and EJB
Date Sun, 09 Apr 2006 07:52:30 GMT
Hi!

Isn't it java:comp/env/ejb/<name of ejb> where the ejb can be looked up? I
remember some examples
where /ejb was the "sub-level" for EJBs.
And can you tell me about the names? I mean, I have an ejb-name written in
ejb-jar.xml. Is this the definitive name for the component which I have to
use everywhere? Or has the name of the remote interface to be referenced
somewhere? I'm actually asking because I played a bit with these names bit
never succeeded.

Thanks much,

Fabian

-----Original Message-----
From: ammulder@gmail.com [mailto:ammulder@gmail.com] On Behalf Of Aaron
Mulder
Sent: Saturday, April 08, 2006 5:44 PM
To: user@geronimo.apache.org
Subject: Re: References between Webapp and EJB

Yes, you need an EJB Ref (or more likely an EJB Local Ref) in web.xml.
 If the WAR and EJB JAR are in the same EAR, then the ejb-link in the EJB
ref should point to the ejb-name of the EJB and that should make it work.
If the WAR and EJB JAR are separate, then you need a geronimo-web.xml with a
matching ejb-ref or ejb-local-ref that resolves the reference to the EJB in
the standalone EJB JAR.

Once you have the EJB ref, the servlet can look up the EJB in JNDI at the
location java:comp/env/(name of EJB ref)

Thanks,
    Aaron

On 4/8/06, Fabian Dankof <fabian@dankof.net> wrote:
> Hello!
>
> I'm trying to get a simple example thing to work that consists of an EJB
and a webapp.
> Up to now I don't know exactly how references between webapps and ejbs are
made.
> Additionally I don't know which files I actually need.
>
> I've got the following deployment descriptors:
>
> ejb-jar.xml:
> --------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
>
>    <description><![CDATA[StringMirrorEJB generated by eclipse wtp xdoclet
extension.]]></description>
>    <display-name>StringMirrorEJB</display-name>
>
>    <enterprise-beans>
>
>       <!-- Session Beans -->
>       <session id="Session_MyStringMirror">
>          <description><![CDATA[A session bean named
MyStringMirror]]></description>
>          <display-name>MyStringMirror</display-name>
>
>          <ejb-name>MyStringMirror</ejb-name>
>
>          <home>foo.MyStringMirrorHome</home>
>          <remote>foo.MyStringMirror</remote>
>          <local-home>foo.MyStringMirrorLocalHome</local-home>
>          <local>foo.MyStringMirrorLocal</local>
>          <ejb-class>foo.MyStringMirrorSession</ejb-class>
>          <session-type>Stateless</session-type>
>          <transaction-type>Container</transaction-type>
>       </session>
>    </enterprise-beans>
>
> </ejb-jar>
> --------------------------------------------------------------
>
> Here is my question if i need an additional 'id' attribute in the 
> <ejb-jar> tag and which value it should have. I already noticed that 
> the value in the 'id' attribute is taken as 'Component Name' in Geronimo
Console.
>
>
> Here is my web.xml:
>
> ---------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <web-app id="web-app_1" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
>    <display-name>SimpleEJBConsumer</display-name>
>    <distributable/>
>
>
>    <servlet>
>       <display-name>SimpleEJBConsumer</display-name>
>       <servlet-name>SimpleEJBConsumer</servlet-name>
>       <servlet-class>foo.SimpleEJBConsumer</servlet-class>
>
>    </servlet>
>
>
>    <servlet-mapping>
>       <servlet-name>SimpleEJBConsumer</servlet-name>
>       <url-pattern>/SimpleEJBConsumer</url-pattern>
>    </servlet-mapping>
>  </web-app>
> ---------------------------------------------------------------
>
> Do i need an ejb-ref in the web.xml???
>
>
> geronimo-web.xml:
>
> ---------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?> <web-app 
> xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
configId="SimpleEJBConsumer/SimpleEJBConsumer">
>   <context-root>/SimpleEJBConsumer</context-root>
>   <context-priority-classloader>false</context-priority-classloader>
>   <nam:ejb-ref>
>         <nam:ref-name>ejb/MyStringMirror</nam:ref-name>
>
<nam:target-name>geronimo.server:J2EEServer=geronimo,j2eeType=StatelessSessi
onBean,name=MyStringMirror</nam:target-name>
>   </nam:ejb-ref>
> </web-app>
> ---------------------------------------------------------------
>
>
> I would be very glad if someone can just tell my what is needed, and what
is not.
>
>
> Thanks,
>
> Fabian
>
>
>


Mime
View raw message