aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Naming Not Found Exception 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 » Java » EJB and other Java EE Technologies
Bookmark "Naming Not Found Exception" Watch "Naming Not Found Exception" New topic
Author

Naming Not Found Exception

Chandrasekhar Vidhyadharani
Greenhorn

Joined: Mar 05, 2004
Posts: 11
hi this is my first post here.
Just learning ejb/j2ee stuff.
I am doing a shopping cart application. I am trying to following MVC2 pattern. I am using local interfaces here.I am using CMP2.0 entity beans. In the client code(servlet) I am doing lookup for my entity bean. here is my lookup code and follows my naming not found exception error console messages.
Now my question is where should i put or enter the jndi names. Is there any procedure? I am following bottom up approach. I am specifying JNDI name in the deployment descriptor( LIke in wsad i am doing like going to ejb deployment descriptor open with deployment descriptor editor and then going to references tab and then selecting the bean and creating a reference and then gave the jndi name. after all these things i am also doing generate>>deploy and rmic code. but nothing helps.
Also i created a reference for my entity bean in the web.xml by going to web deployment descriptor and then open with deployment descriptor editor and then going to references tab and then added the reference to the ejb.
Is there anything i am missing? Please help.
Customer29LocalHome customer29LocalHome = null;
Customer29Local customer29Local = null;
Customer29Key customer29Key = new Customer29Key();//null;
Context env =null;
try{
System.out.println("Getting the IntialContext...");
env = (Context)new InitialContext().lookup("java:comp/env");
}catch (javax.naming.NamingException e) {
System.err.println("Whoops! Threw a NamingException: " + e);
e.printStackTrace(); }
// Perform the lookup
try{
System.out.println("Performing the lookup..");
customer29LocalHome = (Customer29LocalHome)env.lookup("ejb/Customer29LocalHome111");
customer29LocalHome = (Customer29LocalHome)
PortableRemoteObject.narrow(env,Customer29LocalHome.class);
PortableRemoteObject.narrow(obj,Customer29LocalHome.class);}
catch (javax.naming.NamingException e) {
System.err.println("Whoops! Error retrieving the home interface: " + e);
e.printStackTrace();
}
Here are my messages from console
*** Starting the server ***
************ Start Display Current Environment ************
WebSphere Platform 5.0 [BASE 5.0.0 s0245.03] running with process name localhost\localhost\server1 and process id 2132
Host Operating System is Windows 2000, version 5.0
Java version = J2RE 1.3.1 IBM Windows 32 build cn131-20021107 (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
was.install.root = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5
user.install.root = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5
Java Home = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5\java\jre
ws.ext.dirs = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/java/lib;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/classes;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/classes;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/ext;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/web/help;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime;D:/Program Files/IBM/SQLLIB/java/db2java.zip;C:/Program Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.webservice_5.0.1/runtime/worf.jar
Classpath = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/properties;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/properties;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/bootstrap.jar;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/j2ee.jar;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/lmproxy.jar;C:/Program Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.0.1/runtime/wteServers.jar;C:/Program Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.0.1/runtime/wasToolsCommon.jar
Java Library path = C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/bin;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/java/bin;C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/java/jre/bin;C:\Program Files\IBM\WebSphere Studio\eclipse\jre\bin;.;C:\WINNT\system32;C:\WINNT;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Symantec\Norton Ghost 2003\;C:\Sun\AppServer\jdk\bin;C:\Program Files\IBM\WebSphere Studio;D:\PROGRA~1\IBM\SQLLIB\BIN;D:\PROGRA~1\IBM\SQLLIB\FUNCTION;D:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;D:\Program Files\IBM\SQLLIB\BIN
************* End Display Current Environment *************
[3/6/04 17:44:05:578 EST] 677211de ManagerAdmin I TRAS0017I: The startup trace state is *=all=disabled.
[3/6/04 17:44:07:240 EST] 677211de AdminInitiali A ADMN0015I: AdminService initialized
[3/6/04 17:44:10:084 EST] 677211de Configuration A SECJ0215I: Successfully set JAAS login provider configuration class to com.ibm.ws.security.auth.login.Configuration.
[3/6/04 17:44:10:275 EST] 677211de SecurityDM I SECJ0231I: The Security component's FFDC Diagnostic Module com.ibm.ws.security.core.SecurityDM registered successfully: true.
[3/6/04 17:44:11:917 EST] 677211de SecurityCompo I SECJ0309I: Java 2 Security is disabled.
[3/6/04 17:44:11:977 EST] 677211de SecurityCompo I SECJ0212I: WCCM JAAS configuration information successfully pushed to login provider class.
[3/6/04 17:44:12:177 EST] 677211de SecurityCompo I SECJ0240I: Security service initialization completed successfully
[3/6/04 17:44:12:217 EST] 677211de JMSRegistrati A MSGS0602I: WebSphere Embedded Messaging Client only has been installed
[3/6/04 17:44:18:687 EST] 677211de JMXSoapAdapte A ADMC0013I: SOAP connector available at port 8880
[3/6/04 17:44:18:727 EST] 677211de SecurityCompo I SECJ0243I: Security service started successfully
[3/6/04 17:44:18:727 EST] 677211de SecurityCompo I SECJ0210I: Security enabled false
[3/6/04 17:44:21:971 EST] 677211de ResourceMgrIm I WSVR0049I: Binding Casedb2datasource_CF as eis/casedb2jndi_CMP
[3/6/04 17:44:22:052 EST] 677211de ResourceMgrIm I WSVR0049I: Binding casedb1 as casedb2jndi
[3/6/04 17:44:24:275 EST] 677211de CacheServiceI I DYNA0048I: WebSphere Dynamic Cache initialized successfully.
[3/6/04 17:44:24:705 EST] 677211de FileBeanStore W CNTR0023W: Directory "C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/temp" does not exist. The EJB Container will use the current directory for passivating beans.
[3/6/04 17:44:32:376 EST] 677211de ApplicationMg A WSVR0200I: Starting application: IBMUTC
[3/6/04 17:44:32:797 EST] 677211de WebContainer A SRVE0161I: IBM WebSphere Application Server - Web Container. Copyright IBM Corp. 1998-2002
[3/6/04 17:44:33:007 EST] 677211de WebContainer A SRVE0162I: Servlet Specification Level: 2.3
[3/6/04 17:44:33:027 EST] 677211de WebContainer A SRVE0163I: Supported JSP Specification Level: 1.2
[3/6/04 17:44:33:248 EST] 677211de WebContainer A SRVE0169I: Loading Web Module: IBM Universal Test Client.
[3/6/04 17:44:33:728 EST] 677211de WebGroup I SRVE0180I: [IBM Universal Test Client] [/UTC] [Servlet.LOG]: JSP 1.2 Processor: init
[3/6/04 17:44:34:189 EST] 677211de WebGroup I SRVE0180I: [IBM Universal Test Client] [/UTC] [Servlet.LOG]: SimpleFileServlet: init
[3/6/04 17:44:34:399 EST] 677211de ApplicationMg A WSVR0221I: Application started: IBMUTC
[3/6/04 17:44:34:419 EST] 677211de ApplicationMg A WSVR0200I: Starting application: CaseStudy
[3/6/04 17:44:34:500 EST] 677211de EJBContainerI I WSVR0207I: Preparing to start EJB jar: CaseStudyEJBProject.jar
[3/6/04 17:44:35:571 EST] 677211de EJBContainerI I WSVR0037I: Starting EJB jar: CaseStudyEJBProject.jar
[3/6/04 17:44:36:823 EST] 677211de ConnectionFac I J2CA0107I: Component-managed authentication alias not specified for connection factory or datasource Casedb2datasource_CF.
[3/6/04 17:44:37:574 EST] 677211de WebContainer A SRVE0169I: Loading Web Module: CaseStudyWeb.
[3/6/04 17:44:37:724 EST] 677211de WebGroup I SRVE0180I: [CaseStudyWeb] [/CaseStudyWeb] [Servlet.LOG]: JSP 1.2 Processor: init
[3/6/04 17:44:37:834 EST] 677211de WebGroup I SRVE0180I: [CaseStudyWeb] [/CaseStudyWeb] [Servlet.LOG]: SimpleFileServlet: init
[3/6/04 17:44:37:874 EST] 677211de WebGroup I SRVE0180I: [CaseStudyWeb] [/CaseStudyWeb] [Servlet.LOG]: InvokerServlet: init
[3/6/04 17:44:37:934 EST] 677211de ApplicationMg A WSVR0221I: Application started: CaseStudy
[3/6/04 17:44:38:055 EST] 677211de HttpTransport A SRVE0171I: Transport http is listening on port 9,080.
[3/6/04 17:44:40:839 EST] 677211de HttpTransport A SRVE0171I: Transport https is listening on port 9,443.
[3/6/04 17:44:40:949 EST] 677211de RMIConnectorC A ADMC0026I: RMI Connector available at port 2809
[3/6/04 17:44:41:049 EST] 677211de WsServer A WSVR0001I: Server server1 open for e-business
[3/6/04 17:45:03:521 EST] 3b2051ca WebGroup I SRVE0180I: [CaseStudyWeb] [/CaseStudyWeb] [Servlet.LOG]: Register: init
[3/6/04 17:45:03:521 EST] 3b2051ca SystemOut O Getting the IntialContext...
[3/6/04 17:45:03:551 EST] 3b2051ca SystemOut O com.ibm.ws.naming.java.javaURLContext(java:comp/env)
[3/6/04 17:45:03:551 EST] 3b2051ca SystemOut O Performing the lookup..
[3/6/04 17:45:03:561 EST] 3b2051ca SystemErr R Whoops! Error retrieving the home interface: javax.naming.NameNotFoundException: Name ejb not found in context "java:comp/env".
[3/6/04 17:45:03:561 EST] 3b2051ca SystemErr R javax.naming.NameNotFoundException: Name ejb not found in context "java:comp/env".
[3/6/04 17:45:03:571 EST] 3b2051ca SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1648)
[3/6/04 17:45:03:571 EST] 3b2051ca SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:990)
[3/6/04 17:45:03:571 EST] 3b2051ca SystemErr R at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1211)
[3/6/04 17:45:03:571 EST] 3b2051ca SystemErr R at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1257)
[3/6/04 17:45:03:581 EST] 3b2051ca SystemErr R at shop.servlet.Register.doPost(Register.java:62)
[3/6/04 17:45:03:581 EST] 3b2051ca SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[3/6/04 17:45:03:581 EST] 3b2051ca SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[3/6/04 17:45:03:591 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[3/6/04 17:45:03:591 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[3/6/04 17:45:03:591 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[3/6/04 17:45:03:601 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[3/6/04 17:45:03:611 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
[3/6/04 17:45:03:611 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[3/6/04 17:45:03:621 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[3/6/04 17:45:03:621 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
[3/6/04 17:45:03:621 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
[3/6/04 17:45:03:631 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
[3/6/04 17:45:03:631 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[3/6/04 17:45:03:631 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
[3/6/04 17:45:03:641 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[3/6/04 17:45:03:641 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[3/6/04 17:45:03:641 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
[3/6/04 17:45:03:872 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[3/6/04 17:45:03:872 EST] 3b2051ca SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
[3/6/04 17:45:03:882 EST] 3b2051ca SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
[3/6/04 17:45:03:882 EST] 3b2051ca SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
[3/6/04 17:45:03:942 EST] 3b2051ca SystemErr R Whoops! Exception creating new Customer29Local: java.lang.NullPointerException
[3/6/04 17:45:03:942 EST] 3b2051ca SystemErr R java.lang.NullPointerException
[3/6/04 17:45:03:942 EST] 3b2051ca SystemErr R at shop.servlet.Register.doPost(Register.java:79)
[3/6/04 17:45:03:942 EST] 3b2051ca SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[3/6/04 17:45:03:952 EST] 3b2051ca SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[3/6/04 17:45:03:952 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[3/6/04 17:45:03:952 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[3/6/04 17:45:03:962 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[3/6/04 17:45:03:962 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[3/6/04 17:45:03:962 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
[3/6/04 17:45:03:972 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[3/6/04 17:45:03:972 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[3/6/04 17:45:03:972 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
[3/6/04 17:45:03:982 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
[3/6/04 17:45:03:982 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
[3/6/04 17:45:03:982 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[3/6/04 17:45:03:992 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
[3/6/04 17:45:04:002 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[3/6/04 17:45:04:052 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[3/6/04 17:45:04:062 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
[3/6/04 17:45:04:062 EST] 3b2051ca SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[3/6/04 17:45:04:062 EST] 3b2051ca SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
[3/6/04 17:45:04:062 EST] 3b2051ca SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
[3/6/04 17:45:04:072 EST] 3b2051ca SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
[3/6/04 17:45:04:413 EST] 3b2051ca WebGroup I SRVE0180I: [CaseStudyWeb] [/CaseStudyWeb] [Servlet.LOG]: /confirm.jsp: init
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Did you define the JNDI name on the deployment descriptor for the EJB itself?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Chandrasekhar Vidhyadharani
Greenhorn

Joined: Mar 05, 2004
Posts: 11
Yes I did. How? I went to deployment descriptor editor(wsad) and then clicking on the beans tab and then selecting the beans tab and then entered the jndi name & CMP Container Factory JNDI name for the "Websphere Bindings". Also i created references for the entity beans by going to refences tab (Add>>Select EJB Local Reference>>Link>>Browse>>Select the bean for which i want to create the reference). But still i am getting the namenot found exception. What is the exact string i need to pass for the initialcontext.lookup in case of local interfaces? thanks in advance
Chandrasekhar Vidhyadharani
Greenhorn

Joined: Mar 05, 2004
Posts: 11
Huraah. I found the solution. Actually lookup("string") should be the combination of java:comp/env and then the reference name. The reference name need not be same as that of the jndi name. I was able to solve this problem.The final string should be java:comp/env/ejb/Customer29LocalHome where ejb/Customer29LocalHome is the reference name for my entity bean created in web dd editor under ref. tab.
No i have a different problem scenario. html>>servlet>>statelesssessionbean>>cmpentitybean>>
Here i am able to lookup my stateless session bean from servlet. but i could not lookup my entity bean. During lookup what string should i pass to the lookup method? Why don't we pass "java:comp/env" here? What does "java:comp/env" mean and what do we call this? Should i create a reference for my entity bean? ( What i mean is going to ejb DDEDitor/References tab and then select my entity bean and then add a ref to that). Why i am saying coz in the beans tab i am able to see the jndi name for my entity name.
Can somebody help please.
Thanks in advance
Chandoo :!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Naming Not Found Exception