From user-return-13500-apmail-geronimo-user-archive=geronimo.apache.org@geronimo.apache.org Thu Jun 18 11:56:23 2009 Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 45214 invoked from network); 18 Jun 2009 11:56:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jun 2009 11:56:22 -0000 Received: (qmail 4732 invoked by uid 500); 18 Jun 2009 11:56:32 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 4674 invoked by uid 500); 18 Jun 2009 11:56:32 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 4590 invoked by uid 99); 18 Jun 2009 11:56:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2009 11:56:32 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rwonly@gmail.com designates 209.85.216.201 as permitted sender) Received: from [209.85.216.201] (HELO mail-px0-f201.google.com) (209.85.216.201) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2009 11:56:22 +0000 Received: by pxi39 with SMTP id 39so858382pxi.27 for ; Thu, 18 Jun 2009 04:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=C7EhxrC2RBqFSuYHmWLipRES+urTQlcYj7G/rhCdTeM=; b=gn2h+8QOgbxofFgF9+JcJdxf9sSxdx67IDwdQGCAlFPq2UI1EfhWMP8mj1p2HY9bBP Xdcmuzmt43Cmi8gE/w/80rSWd8CBaWUqwpf7ok8czyCaGAA0ylvIO11Z6vy6Fmp+uISS V6Htut69Xzu+aw+NDgG6xt6NSw0G7kiEw6nSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Xgs8rRF76W2BqQ6/hW1R+YMf/UCK2iq15cL9nfSID3A5xidm2beVoj+aY++3wCxZHp 3A6z5UPimhrf1AM9oOJYTbErD9nW2WeyFRB3juH5fN2AnnQPEX2gvfNq6iVXUIP+OGrf L+GUoYt9xJO8THT8BJtSvIF/46gnkf6AgZebA= MIME-Version: 1.0 Received: by 10.140.144.6 with SMTP id r6mr320883rvd.249.1245326162452; Thu, 18 Jun 2009 04:56:02 -0700 (PDT) In-Reply-To: <24091435.post@talk.nabble.com> References: <24076429.post@talk.nabble.com> <24089247.post@talk.nabble.com> <24091435.post@talk.nabble.com> Date: Thu, 18 Jun 2009 19:56:02 +0800 Message-ID: Subject: Re: JNDI Name for EJB3 From: Rex Wang To: user@geronimo.apache.org Content-Type: multipart/alternative; boundary=000e0cd229608ae355046c9e17b3 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd229608ae355046c9e17b3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 default CurrencyConvertEJB 1.0 car 2 Ref the EJB (1) Method 1 in web.xml-------------- ConverterBean Session ejb.Converter 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------- ejb/SessionBean ConverterBean in web.xml---------------- ejb/SessionBean Session ejb.Converter 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 > > OK, I got it to run with using the sample from > http://cwiki.apache.org/GMOxDOC20/very-simple-session-ejb-example.html > > (which does contain a web.xml) > > > ejb/Secured3 > Session > ejb3.Secured3 > > > 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. > > --000e0cd229608ae355046c9e17b3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable hi Juergen,

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

@Remote
interfac= e Converter

@stateless
public class ConverterBean implements Conv= erter


Web Project=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D

1 Add dependency in geronimo-web.xml
=A0=A0=A0 <sys:dependency>= ;
=A0=A0=A0=A0=A0=A0=A0 <sys:groupId>default</sys:groupId>=A0=A0=A0=A0=A0=A0=A0 <sys:artifactId>CurrencyConvertEJB</sys:ar= tifactId>
=A0=A0=A0=A0=A0=A0=A0 <sys:version>1.0</sys:versio= n>
=A0=A0=A0=A0=A0=A0=A0 <sys:type>car</sys:type>
=A0=A0=A0 <= ;/sys:dependency>

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


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


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

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

in jsp--------------------
=A0=A0=A0 &= lt;%@ page import=3D"javax.naming.*" %>
=A0=A0=A0 <%@ pa= ge import=3D"ejb.Converter" %>
=A0=A0=A0 <%
=A0=A0=A0= Context ctx =3D new InitialContext();
=A0=A0=A0 Converter ref =3D (Converter)ctx.lookup("java:comp/env/ejb/S= essionBean");
=A0=A0=A0 %>


=A0

=A0=A0=A0
=

HTH.

Rex


2009/6/18 Jue= rgen Weber <weber= jn@gmail.com>

OK, I got it to run with <ejb-local-ref> using the sample from
http://cwiki.apache.org/GMOxDOC20/very-simple-ses= sion-ejb-example.html

(which does contain a web.xml)

=A0 =A0 =A0 =A0<ejb-local-ref>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<ejb-ref-name>ejb/Secured3</ejb-re= f-name>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<ejb-ref-type>Session</ejb-ref-typ= e>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<local>ejb3.Secured3</local>
=A0 =A0 =A0 =A0</ejb-local-ref>

context =3D new InitialContext();
Secured3 secured3 =3D (Secured3) context.lookup("java:comp/env/ejb/Sec= ured3");

I also needed a sys:dependency from geronimo-web.xml to openejb-jar.xml to<= br> 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<= br> JNDI is from a different (the ejb) classloader than the cast target which i= s
from the web application).

Thanks,
Juergen


--
View this message in context: http://www.nabble.co= m/JNDI-Name-for-EJB3-tp24076429s134p24091435.html
Sent from the Apache Geronimo - Us= ers mailing list archive at Nabble.com.


--000e0cd229608ae355046c9e17b3--