Re: (Newbee)Websphere 5.0 Local Lookup
"Parameswaran Nair, Kiran Kumar (Cognizant)" <[email protected]> Mon, 3 May 2004 22:19:32 +0530
| Newsgroups | gmane.comp.java.sun.ejb.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
For accessing java:comp namespace in your web module you should add
a resource referece to your ejb in your web.xml.
Here's a sample.
<ejb-ref id="EjbRef_1083562973290">
<ejb-ref-name>FirstStatelessBeanAlias</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>raj.ejb.session.stateless.FirstHome</home>
<remote>raj.ejb.session.stateless.First</remote>
<ejb-link>TestEjb.jar#First</ejb-link>
</ejb-ref>
While doing a lookup you should use the resource reference name instread
of the global jndi name.
localHome=(FirstLocalHome)ctx.lookup("java:comp/env/FirstStatelessBeanAl
ias");
Thanks,
Kiran.
_____
From: A mailing list for Enterprise JavaBeans development
[mailto:[email protected]] On Behalf Of Raj
Sent: Sunday, May 02, 2004 11:41 PM
To: [email protected]
Subject: (Newbee)Websphere 5.0 Local Lookup
Hi,
I am a newbee to EJB programming and I am trying to develop my first ejb
on WSAD5.0, I just programmed a session bean which returns a simple
String through a getMessage method.
I am trying to lookup this EJB through a jsp page and I am getting a
NameNotFoundException.
I searched several forums including this one and tried to implement
according to the recommendations given here. But the problem still
persists. My code goes as follows.
ejb-jar.xml (generated by WSAD)
-------------
<?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_ID">
<display-name>rajEjb</display-name>
<enterprise-beans>
<session id="FirstBean">
<ejb-name>FirstBean</ejb-name>
<local-home>raj.ejb.session.stateless.FirstLocalHome</local-home>
<local>raj.ejb.session.stateless.First</local>
<ejb-class>raj.ejb.session.stateless.FirstBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
ibm-ejb-bnd-jar.xmi(also generated by WSAD)
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejbbnd:EJBJarBinding xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:ejbbnd="ejbbnd.xmi"
xmlns:ejb="ejb.xmi" xmi:id="EJBJarBinding_1083440172703">
<ejbJar href="META-INF/ejb-jar.xml#ejb-jar_ID"/>
<ejbBindings xmi:id="EnterpriseBeanBinding_1083440172703"
jndiName="FirstStatelessBean">
<enterpriseBean xmi:type="ejb:Session"
href="META-INF/ejb-jar.xml#FirstBean"/>
</ejbBindings>
</ejbbnd:EJBJarBinding>
index.jsp (where lookup is made)
-----------------------------------
<%! private Context ctx = null;
private FirstLocalHome localHome;
%>
<%
try{
ctx = new InitialContext();
localHome=(FirstLocalHome)ctx.lookup("java:comp/env/FirstStatelessBean")
;
}catch(NamingException eNE){
System.out.println("Naming Exception");
eNE.printStackTrace(); }
%>
and the following exception is thrown when JSP page is called.
O Naming Exception
[5/2/04 13:38:21:163 EDT] 42bb80ab SystemErr R
javax.naming.NameNotFoundException: Name "comp/env/FirstStatelessBean"
not found in context "java:".
[5/2/04 13:38:21:163 EDT] 42bb80ab SystemErr R at
com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1003)
[5/2/04 13:38:21:163 EDT] 42bb80ab SystemErr R at
com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1211)
[5/2/04 13:38:21:163 EDT] 42bb80ab SystemErr R at
com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1203)
[5/2/04 13:38:21:163 EDT] 42bb80ab SystemErr R ...................
Can anyone of you tell me how to lookup the EJB and solve my problem.
It would be a great help for me.
thanks in advance.
Raj.
_____
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
<http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/hotjobs_mail_signat
ure_footer_textlink/evt=23983/*http://hotjobs.sweepstakes.yahoo.com/care
ermakeover>
========================================================================
=== To unsubscribe, send email to [email protected] and include in
the body of the message "signoff EJB-INTEREST". For general help, send
email to [email protected] and include in the body of the message
"help".
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[email protected] and include in the body of the message "help".
InterScan_Disclaimer.txt
(text/plain, 825 B)
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.
Visit us at http://www.cognizant.com
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[email protected] and include in the body of the message "help".