• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
------------------------------
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alpesh Parekh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'm all tasted up for a BLT! This tiny ad wants a monte cristo!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic