aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes I got a NamingContextPackage.NotFound Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "I got a NamingContextPackage.NotFound Exception" Watch "I got a NamingContextPackage.NotFound Exception" New topic
Author

I got a NamingContextPackage.NotFound Exception

Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
Hi all,

I am new to EJB's and First time creating EJB's in Websphere Version: 5.1.2. I have created the bean project in the Websphere and written a method myMethod() in which I have written "Hello Bean".

This is running absolutely fine when I test the Bean with the websphere's own JNDI explorer and its giving me the message what I have written in myMethod().

The same thing when I tried to Run using 1. Servlet OR 2. JSP OR 3. Plain Java class with main() (I created the new dynamic web project)I am not getting the desired output and getting the error.

There are no compilation error in the code also the packaging and placing of Beans is not an issue because the websphere is itself creating everything.


***********Error in Running servlet is ************

[2/27/07 16:01:46:950 IST] 7b388473 WebGroup I SRVE0180I: [HelloWeb] [/HelloWeb] [Servlet.LOG]: Test: init
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: jndiname: First component in name jndiname not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:968)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:1399)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3491)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)



Let me know if you need any further help from my side I can provide the code of my Home/Remore/Implementation class But as I said everything is created by Websphere and there is no problem with the code as its running fine with its own JNDI explorer.

**************My EJB deployment descriptor is as below (This is created by Websphere)**********

<?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>FirstEJB</display-name>
<enterprise-beans>
<session id="HelloBean">
<ejb-name>HelloBean</ejb-name>
<home>com.HelloBeanHome</home>
<remote>com.HelloBean</remote>
<ejb-class>com.HelloBeanBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


Thanks in advance for any help.

PS: I have also added the class path entry in my dynamic project where my servlet/jsp is located.
[ March 01, 2007: Message edited by: Mark Spritzler ]

Siddharth Purandare<br />SCJP 1.4 - 76%<br />SCWCD 1.4 - 85%<br /> <br />It is the "attitude" and not the "aptitude" which determines "altitude".
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10255
    
168

Can you post the code you have for doing the lookup? What's the jndi name that you are passing to the lookup method?


[My Blog] [JavaRanch Journal]
Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
Hi, Thanks for showing interest in my thread. I am using the below code in my servlet. I also tried the same code in JSP as well as plain java class. The same JNDI name is appearing in my EJB deployment descriptor.



*************Code*************

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

try{
Context ic=new InitialContext();
Object o=ic.lookup("ejb/com/HelloBeanHome");
HelloBeanHome home=(HelloBeanHome) PortableRemoteObject.narrow(o,HelloBeanHome.class);
HelloBean rem=home.create();
rem.myMethod();
}catch(Exception e){
e.printStackTrace();
}

}



**************** Error is as below**************

Test is my Servlet.....

[2/28/07 16:10:36:196 IST] 698fa86a WebGroup I SRVE0180I: [HelloWeb] [/HelloWeb] [Servlet.LOG]: Test: init
[2/28/07 16:10:36:586 IST] 698fa86a WebGroup E SRVE0026E: [Servlet Error]-[com.HelloBeanHome]: java.lang.NoClassDefFoundError: com.HelloBeanHome
at Test.doGet(Test.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[ February 28, 2007: Message edited by: Siddharth Purandare ]
Sumit Malik
Ranch Hand

Joined: Jan 05, 2007
Posts: 84
Hi Siddharth Purandare,

Do check out the jndi name of the interface on weblogic server. Since, what its shown in the log trace is weblogic server is unable to locate any object attached the jndi name what you are referring(or calling) through your client code.

I hope once you gonna call it with exact jndi name what server has assigned to your ejb interface then your problem get resolved.

Cheers !!!
Sumit Malik


If at first you don't succeed, don't try skydiving
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10255
    
168

java.lang.NoClassDefFoundError: com.HelloBeanHome
at Test.doGet(Test.java:31)


Looks like a classpath issue. Have you included the com.HelloBeanHome and the other related classes in the classpath of the application?
[ February 28, 2007: Message edited by: Jaikiran Pai ]
Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
Hi All,

Thanks for all your help. I got the solution now. The web.xml of my web project and EJB deployment of my EJB project were not on sync with each other. I studied both the files and the related entries for <ejb-ref> in both the files was corrected by me to Run my First EJB application.

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I got a NamingContextPackage.NotFound Exception