File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Alpesh Parekh
Greenhorn
Posts: 12
  • 0
  • 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>
------------------------------
 
Scott Duncan
Ranch Hand
Posts: 364
  • 0
  • 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
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic