This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

NameNotFoundException

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am having this error in my jdeveloper environment when i tried to connect entity bean from session bean.
05/12/22 20:06:25 javax.naming.NameNotFoundException: Ship not found in SessionEJB

05/12/22 20:06:25 at com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:93)
My ejb-jar.xml contains
<entity>
<description>Entity Bean ( CMP )</description>
<display-name>Ship</display-name>
<ejb-name>Ship</ejb-name>
<local-home>com.ocm.ShipLocalHome</local-home>
<local>com.ocm.ShipLocal</local>
<ejb-class>com.ocm.ShipBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>


and in session bean i am trying like this
InitialContext ctx = OcmLocationMasterData.getInitialContext();
System.out.println("Context has been initialized");

Object objref=ctx.lookup("java:comp/env/Ship");
System.out.println("lookup finished");
ShipLocalHome home=(ShipLocalHome)PortableRemoteObject.narrow(objref,ShipLocalHome.class);
Long id = new Long(1);
ShipLocal result=home.create(id,"INSkundan","kolkata");

For initial context i am doing just
return new InitialContext();

Thanks for the help
kundan
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by kundan varma:
Object objref=ctx.lookup("java:comp/env/Ship");


Do the following:

Object objref=ctx.lookup("com.ocm.ShipLocal");
 
You've gotta fight it! Don't give in! Read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!