Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Naming.NotFoundException

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call a local session bean but I keep getting the
javax.Naming.NotFound exception error.
I created a local session bean called AdviceLocal bean and created the two interfaces as shown in chapter 3.
I am trying to call the local bean from the remote bean AdviceBean.
But when I do the commands:
Context ic = new InitialContext();
Object o = ic.lookup("AdvisorLocal");

I get the exception. How can I call the local bean?
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AdviceBean (remote bean) should have ejb-ref section for local bean and then refer to the local bean in remote bean like
Context ic = new InitialContext();
Object o = ic.lookup("java:comp/env/AdvisorLocal");

I don't have work experience, this is depending on the material I read so far. Please correct me if it is wrong.
 
Dave Trower
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using
Object o = ic.lookup("java:comp/env/AdvisorLocal");
but then I got the error:
javax.naming.NameNotFoundException: No object bound to
name java:comp/env/AdvisorLocal
 
gopi chillakuru
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post your deployment descriptor(ejb-jar.xml) for the portion in enterprise-beans section for remote and local beans.
 
Dave Trower
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the XML:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE j2ee-ri-specific-information (View Source for full doctype...)>
- <j2ee-ri-specific-information>
<rolemapping />
- <enterprise-beans>
<module-name>ejb-jar-ic.jar</module-name>
<unique-id>545446468</unique-id>
- <ejb>
<ejb-name>AdviceBean</ejb-name>
<jndi-name>Advisor</jndi-name>
- <ior-security-config>
- <transport-config>
<integrity>supported</integrity>
<confidentiality>supported</confidentiality>
<establish-trust-in-target>supported</establish-trust-in-target>
<establish-trust-in-client>supported</establish-trust-in-client>
</transport-config>
- <as-context>
<auth-method>username_password</auth-method>
<realm>default</realm>
<required>false</required>
</as-context>
- <sas-context>
<caller-propagation>supported</caller-propagation>
</sas-context>
</ior-security-config>
- <gen-classes>
<remote-home-impl>headfirst.AdviceBean_RemoteHomeImpl</remote-home-impl>
<remote-impl>headfirst.AdviceBean_EJBObjectImpl</remote-impl>
</gen-classes>
</ejb>
- <ejb>
<ejb-name>LocalAdviceBean</ejb-name>
<jndi-name>AdvisorLocal</jndi-name>
- <ior-security-config>
- <transport-config>
<integrity>supported</integrity>
<confidentiality>supported</confidentiality>
<establish-trust-in-target>supported</establish-trust-in-target>
<establish-trust-in-client>supported</establish-trust-in-client>
</transport-config>
- <as-context>
<auth-method>username_password</auth-method>
<realm>default</realm>
<required>false</required>
</as-context>
- <sas-context>
<caller-propagation>supported</caller-propagation>
</sas-context>
</ior-security-config>
- <gen-classes>
<local-home-impl>headfirst.LocalAdviceBean_LocalHomeImpl</local-home-impl>
<local-impl>headfirst.LocalAdviceBean_EJBLocalObjectImpl</local-impl>
</gen-classes>
</ejb>
</enterprise-beans>
</j2ee-ri-specific-information>
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
U dnt have the ejb-ref element.U have to add ref to ur local bean to AdviceBean.The local bean is in private env.so the lookup in java:comp/env
is needed.What the guy mentioned above is correct
 
Let's get him boys! We'll make him read this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic