This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

what is this error  RSS feed

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!