Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Websphere and the fly likes NameNotFoundException  Name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "NameNotFoundException  Name "comp/env /ejb/HelloBeanRemote" not found" Watch "NameNotFoundException  Name "comp/env /ejb/HelloBeanRemote" not found" New topic
Author

NameNotFoundException Name "comp/env /ejb/HelloBeanRemote" not found

Alpesh Parekh
Greenhorn

Joined: Aug 05, 2002
Posts: 12
HI,
I have developed a simple Session bean with ejb reference. In web module slso i have created local and remote reference for this EJB. When i tried to call ejb (from JSP) by this reference it gives following error.
javax.naming.NameNotFoundException: Name "comp/env/ejb/HelloBeanRemote" not found in context "java:"

1) My JSP code is ...
Object homeObj2 = ctx.lookup("java:comp/env/ejb/HelloBeanRemote");
----------------------------------------------------------
2) I generated descriptor files using AAT (WAS 5.0).
My web.xml is ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <web-app id="WebApp_ID">
<display-name>HelloWeb</display-name>
<description>Web module for Hello EJB</description>
- <servlet id="Servlet_1059657965808">
<servlet-name>IndextPage</servlet-name>
<jsp-file>Index.jsp</jsp-file>
</servlet>
- <welcome-file-list id="WelcomeFileList_1059657965818">
<welcome-file>IndexPage</welcome-file>
</welcome-file-list>
- <ejb-ref id="EjbRef_1059658267678">
<description>Reference to remote in WEB</description>
<ejb-ref-name>ejb/HelloBeanRemoteWEB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.ant1.business.hello.HelloHome</home>
<remote>com.ant1.business.hello.Hello</remote>
<ejb-link>HelloEJB</ejb-link>
</ejb-ref>
- <ejb-local-ref id="EJBLocalRef_1059658267678">
<description>Reference to local inteface in web.</description>
<ejb-ref-name>ejb/HelloBeanLocalWEB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.ant1.business.hello.LocalHelloHome</local-home>
<local>com.ant1.business.hello.LocalHello</local>
<ejb-link>HelloEJB</ejb-link>
</ejb-local-ref>
</web-app>
----------------------------------------------------------
3) My ejb-jar.xml is ...
- <ejb-jar id="ejb-jar_ID">
<display-name>HelloBean</display-name>
- <enterprise-beans>
- <session id="Session_1059657489864">
<description>This is a Hello EJB.</description>
<display-name>HelloEJB</display-name>
<ejb-name>HelloEJB</ejb-name>
<home>com.ant1.business.hello.HelloHome</home>
<remote>com.ant1.business.hello.Hello</remote>
<local-home>com.ant1.business.hello.LocalHelloHome</local-home>
<local>com.ant1.business.hello.LocalHello</local>
<ejb-class>com.ant1.business.hello.HelloBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
- <ejb-ref id="EjbRef_1059657489874">
<ejb-ref-name>ejb/HelloBeanRemote</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.ant1.business.hello.HelloHome</home>
<remote>com.ant1.business.hello.Hello</remote>
<ejb-link>HelloEJB</ejb-link>
</ejb-ref>
- <ejb-local-ref id="EJBLocalRef_1059657489884">
<description>Local ref to HelloEJB</description>
<ejb-ref-name>ejb/HelloBeanLocal</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.ant1.business.hello.LocalHelloHome</local-home>
<local>com.ant1.business.hello.LocalHello</local>
<ejb-link>HelloEJB</ejb-link>
</ejb-local-ref>
</session>
</enterprise-beans>
....
</ejb-jar>
------------------------------


<b>One life, live it.</b><br /><b>Alpesh</b>
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
generally, by default the lookup name of an ejb in was 4 is essentially 'ejb/' +fully qualified path: for example - "ejb/com/skyllar/ejb/CountHome" where com.skyllar.ejb.CountHome is the fully qualified path + class. Don't know if this helps or not.


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Alpesh Parekh
Greenhorn

Joined: Aug 05, 2002
Posts: 12
I got it. I was using wrong reference.
JSP/Servlet should use refernces defined in WEB.xml.
When i used
Object homeObj2 = ctx.lookup("java:comp/env/ejb/HelloBeanLocalWEB");
or
Object homeObj2 = ctx.lookup("java:comp/env/ejb/HelloBeanRemoteWEB");
And it started to work.
So enjoy and have nice week end.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NameNotFoundException Name "comp/env /ejb/HelloBeanRemote" not found