Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Naming.NotFoundException

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic