Win a copy of Java Challengers 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JNDI Name not found exception

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using weblogic server.

The following lines of code is what i am using in a jsp,
-------------------------In jsp -----------------------
javax.naming.Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(javax.naming.Context.PROVIDER_URL,
"t3://localhost:7001");
ctx = new javax.naming.InitialContext(ht);
EtsBean bean = (EtsBean)ctx.lookup("ejb/EtsHome");

to retrieve the context name

my deployment descriptors contains the following....
-------------------------In ejb-jar.xml -----------------------
<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

<ejb-jar>
<enterprise-beans>
<!-- A minimal session EJB deployment -->
<session>
<ejb-name>EtsHome</ejb-name>
<jndi-name>ejb/EtsHome</jndi-name>
<home>EdenBaseBean.etsEJB.EtsHome</home>
<remote>EdenBaseBean.etsEJB.Ets</remote>
<ejb-class>EdenBaseBean.etsEJB.EtsBean</ejb-class>
<!-- or Stateless -->
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<!-- Assembly Descriptor -->
<assembly-descriptor></assembly-descriptor>
</ejb-jar>

-------------------In weblogic-ejb-jar.xml ----------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">

<weblogic-ejb-jar>
<description>Stateful Session Bean Example</description>
<weblogic-enterprise-bean>
<ejb-name>EtsHome</ejb-name>
<stateful-session-descriptor></stateful-session-descriptor>
<reference-descriptor></reference-descriptor>
<jndi-name>ejb/EtsHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

This is the following error i am getting on the console,
-----------------------Error Trace ---------------------------
javax.naming.NameNotFoundException: While trying to lookup 'ejb.EtsHome' didn't find subcontext 'ejb' Resolved ; remaining name 'ejb/EtsHome'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:897)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:225)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:154)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:188)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:256)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:357)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at jsp_servlet.__selectestimatesfield._jspService(__selectestimatesfield.java:2068)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

--------------------------------------------------

Can anyone help me out in resolving this problem.....
Thanks in advance for your kind help...
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you are using Weblogic try looking up the JNDI tree on the server console before you run your client. It should be under servers.

Also Check your code i use this one works fine.
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
h.put(Context.SECURITY_PRINCIPAL, user);
h.put(Context.SECURITY_CREDENTIALS, password);

Object homeObject = context.lookup("ejb/MyEJB");
MyEJBhome = (MyEJBHome) PortableRemoteObject
.narrow(homeObject, MyEJBHome.class);
remote = home.create();

Hope this helps.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Chandru,
Has your problem been solved?


I think when you do a lookup you should use the following:
context.lookup("java:comp/env/ejb/MyEJB")

Let me know if this solves your problem

Regards,
Paresh Vernekar
 
paresh vernekar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Chandru,
Has your problem been solved?


I think when you do a lookup you should use the following:
context.lookup("java:comp/env/ejb/MyEJB")

Let me know if this solves your problem

Regards,
Paresh Vernekar
 
Chandra S Marappa
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is still persisting...

could anyone tell me whether the DD's are correct or not andif wrong what is the changes i have to do....

if anyone could send me a sample for using an EJB(deploying in WEBlogic 8.1), it would be so nice....


Thanks in advance....
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This exception happend when the property provider.url is pointing at the AdminServer (localhosto:7001, in my case) and there not is installed the JDBC, may be you have other instances where has been installed, check your JNDI TREE to verify this.
Greetings
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic