geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rex Wang <rwo...@gmail.com>
Subject Re: JNDI Name for EJB3
Date Thu, 18 Jun 2009 11:56:02 GMT
hi Juergen,

Here is my note..
EJB Project=================================================

@Remote
interface Converter

@stateless
public class ConverterBean implements Converter


Web Project=================================================

1 Add dependency in geronimo-web.xml
    <sys:dependency>
        <sys:groupId>default</sys:groupId>
        <sys:artifactId>CurrencyConvertEJB</sys:artifactId>
        <sys:version>1.0</sys:version>
        <sys:type>car</sys:type>
    </sys:dependency>

2 Ref the EJB
(1) Method 1
in web.xml--------------
    <ejb-ref>
        <ejb-ref-name>ConverterBean</ejb-ref-name>   <!--actually Convert,
ConvertBeanRemote are also ok-->
        <ejb-ref-type>Session</ejb-ref-type>
        <remote>ejb.Converter</remote>
    </ejb-ref>


in jsp------------------
    <%@ page import="javax.naming.*" %>
    <%@ page import="ejb.Converter" %>
    <%
    Context ctx = new InitialContext();
    Converter ref = (Converter)ctx.lookup("java:comp/env/ConverterBean");
    %>


(2) Method 2
in geronimo-web.xml-------
    <name:ejb-ref>
        <name:ref-name>ejb/SessionBean</name:ref-name>
        <name:ejb-link>ConverterBean</name:ejb-link>
    </name:ejb-ref>

in web.xml----------------
    <ejb-ref>
        <ejb-ref-name>ejb/SessionBean</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <remote>ejb.Converter</remote>
    </ejb-ref>

in jsp--------------------
    <%@ page import="javax.naming.*" %>
    <%@ page import="ejb.Converter" %>
    <%
    Context ctx = new InitialContext();
    Converter ref = (Converter)ctx.lookup("java:comp/env/ejb/SessionBean");
    %>







HTH.

Rex


2009/6/18 Juergen Weber <weberjn@gmail.com>

>
> OK, I got it to run with <ejb-local-ref> using the sample from
> http://cwiki.apache.org/GMOxDOC20/very-simple-session-ejb-example.html
>
> (which does contain a web.xml)
>
>        <ejb-local-ref>
>                <ejb-ref-name>ejb/Secured3</ejb-ref-name>
>                <ejb-ref-type>Session</ejb-ref-type>
>                <local>ejb3.Secured3</local>
>         </ejb-local-ref>
>
> context = new InitialContext();
> Secured3 secured3 = (Secured3)
> context.lookup("java:comp/env/ejb/Secured3");
>
> I also needed a sys:dependency from geronimo-web.xml to openejb-jar.xml to
> make the remote interface known to the JSP (this is missing in the above
> sample).
> First I simply included the ejb.jar into WEB-INF/lib, but this results in
> ClassCastException on JNDI lookup (I guess because the Remote interface in
> JNDI is from a different (the ejb) classloader than the cast target which
> is
> from the web application).
>
> Thanks,
> Juergen
>
>
> --
> View this message in context:
> http://www.nabble.com/JNDI-Name-for-EJB3-tp24076429s134p24091435.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message