• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is this error

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I coded a stateless session bean. It is successfully deployed in J2EE 1.4 Server.
But when I want to run client, I have the error below. Please help me. I almost can not stand the EJB including JBoss / J2EE server.
what is the difference?
1. lookup("name");
2. lookup("java:com/env/ejb/name");
if I set the JNDI name as "name" in descriptor XML file, which one I should use? or are same?
Thanks.
Edward
//--------------------------
C:\temp>java -classpath %CLASSPATH%;C:\temp\TestClient.jar Client
Starting Client . . .
Looking up the sign on component via JNDI.
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:
java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at Client.main(Client.java:18)
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have already posted this reply in someone else's thread. I think I too had the same problem as yours, though I don't remember the exact description of my exception.
I am not sure about my answer. But seeing InitialContextFactory exception in the stack, it reminds me of the problem that I encountered with running my client with beans on a J2EE server.
I installed J2EE, NetBeans ide(which has its own jdk), and BEA weblogic server. having so many versions of JDK caused the problem for me. I found this solution on some website. When I uninstalled Bea and netbeans, my client ran well.
One suggestion(proved useful to me time and again): Paste a significant part of your exception in Google and search.
HTH.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what is the difference?
1. lookup("name");
2. lookup("java:com/env/ejb/name");
if I set the JNDI name as "name" in descriptor XML file, which one I should use? or are same?


No, they're not the same. The "java:comp/env" prefix in a JNDI lookup means that you're making the lookup against the bean's private context -- in other words, there has to be an ejb-ref specified for the EJB in the deployment descriptors, which maps the "logical" JNDI name used by your Java code into a "real" JNDI name with which your EJB was deployed into the appserver's JNDI tree.
See this earlier thread or search this forum for details about ejb-ref.
If the deployment descriptor defines the JNDI name being "name", your lookup code should use "name". If your deployment descriptors define the logical JNDI name being "foo/bar" and the real JNDI name being "name", your lookup code should use "java:comp/env/foo/bar".

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file...

In order to make a JNDI lookup on a remote server, you need to create the InitialContext object by giving its constructor some configuration parameters. We have an example of this in the JavaRanch Wiki: ObtainingRemoteJndiContext
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic