somebody314
asked on
where is jndi.properties for my ejb client applcication?
I have deployed a simple ejb on the Sun Application server on my computer where it is located on :localhost:8080
now i want to write a client application to test and use that ejb but when i cann InitialContext's lookup method it throws a "NoInitialContext" exception and says that : need to specify class name in environment or system property or as applet parameter or application resource file : java.naming.factory.initia l
I searched all of my hard drive and could not find a "jndi.properties" which i think is the solution for my problem .
What should i do now for running my client application?
now i want to write a client application to test and use that ejb but when i cann InitialContext's lookup method it throws a "NoInitialContext" exception and says that : need to specify class name in environment or system property or as applet parameter or application resource file : java.naming.factory.initia
I searched all of my hard drive and could not find a "jndi.properties" which i think is the solution for my problem .
What should i do now for running my client application?
ASKER
but wgat should i add to the hashtable ? which items?
"java.naming.factory.initi
For example, if you're using WebLogic's container, use
env.put("java.naming.facto
and then pass "env" to the InitialContext's ctor.
AviadBD.
BTW, "java.naming.factory.initi
env.put(Context.INITIAL_CO
AviadBd.
ASKER
But how can it find the JNDI server on the application server? i have not set the IP of the server and it's port in the client program , so how can it find where the application server is placed?
Its not where its placed, its the factory which creates it. It is contained in the jar file supplied with the application server.. You should have documentation with the application server.
PS, if you're using Sun's application server, its already configured to it defaultly.
Aviad.
ASKER
I have deployed my ejb and when i run this :
Context ic=new InitialContext();
ic.lookup("java:comp/env/e jb/Hello") ;
or any other string in lookup function a NoInitialContext exception is thrown . even when i construct the intialcontext using Syste.getProperties()
Now what should i do?
I think i have to set some of these variables in a Hashtable and pass it to the initial context's constructor but i do not know the values i shoudl use .
-> java.naming.factory.initia l
-> java.naming.provider.url
Context ic=new InitialContext();
ic.lookup("java:comp/env/e
or any other string in lookup function a NoInitialContext exception is thrown . even when i construct the intialcontext using Syste.getProperties()
Now what should i do?
I think i have to set some of these variables in a Hashtable and pass it to the initial context's constructor but i do not know the values i shoudl use .
-> java.naming.factory.initia
-> java.naming.provider.url
What is your application server? Where do you deploy the EJBs? I'll help you look for the values.
Aviad.
ASKER
the problem is solved :
I should place these two items in the environment hashtable or put them in a jndi.properties file and place it in the root directory of my project :
java.naming.provider.url=i iop://loca lhost:3700
java.naming.factory.initia l=com.sun. jndi.cosna ming.CNCtx Factory
I should place these two items in the environment hashtable or put them in a jndi.properties file and place it in the root directory of my project :
java.naming.provider.url=i
java.naming.factory.initia
Well, good that its solved.
Thats actually what I asked you - Where are the EJBs deployed. But by your resolution, it seems that you use a CORBA Context?
Aviad
ASKER
I think si , How can i use JNDI instead?
Well, there are multiple ways... JNDI can be used to reach a Directory services (Like Active Directory or iPlanet) or even a file system like NTFS, given the right drivers.
Aviad.
ASKER
Ok , but how can i use it ? I have installed Sun Application Server completely so what should i put as a value for initial factory and provider url in the hashtable passed to the initialcontext?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Something to look at:
http://developers.sun.com/sw/building/tech_articles/bindingas65.html
http://developers.sun.com/sw/building/tech_articles/bindingas65.html
ASKER
thanks very much.
as i wrote in a previous comment in 10/26/2004 11:43PM PDT
the problem is solved.
as i wrote in a previous comment in 10/26/2004 11:43PM PDT
the problem is solved.
Well, you could always just add it up to the Hashtable passed to the InitialContext class on construction.
Besides that, you could read this, about application resource files: http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/Context.html#RESOURCEFILES
AviadBD.