File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes InitialContext - don't understand how to set this from an app not hosted by appserver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "InitialContext - don Watch "InitialContext - don New topic
Author

InitialContext - don't understand how to set this from an app not hosted by appserver

marc dauncey
Greenhorn

Joined: Jan 15, 2004
Posts: 21
Hello everyone,

I know this is a common question because I've searched the forum and read through peoples problems and solutions, but I'm still not understanding, and I wondered if I could get some advice.

I have an application client in the form of standalone java classes which calls a remote EJB on a WAS server. I understand i can make a JNDI call to a server and port and I know I have to set the InitialContext, but I don't know what i should set it to.

Lots of people seem to suggest "org.jnp.interfaces.NamingContextFactory" but I'm not sure if this is something appserver specific like JBoss.

What would people advise?

Many thanks


Marc
marc dauncey
Greenhorn

Joined: Jan 15, 2004
Posts: 21
Ok, answering my own question here - worked out that the app needs to run as an application client (rather than invoking main(string[] args) like a normal java app.

Just noticed the mindboggling jvm options i am going to need - this is going to cause me a big problem since my code will be running inside of another java application (IBM extended search) - don't have control of the jvm and really not sure how i am going to get round this.

The fact that you need all this stuff just to make a jndi call and get back an ejb strikes me as tight coupling. Or have I misunderstood?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
can you show the look up code? i have same problem
marc dauncey
Greenhorn

Joined: Jan 15, 2004
Posts: 21
I've now successfully got an ejb lookup working in a POJO without running it as an application client.

Basically for WAS, you need the following JARs on your project classpath:

wssec.jar
naming.jar
namingclient.jar
lmproxy.jar
sas.jar
ecutils.jar

you also need a reference to a folder containing this file:
implfactory.properties

i then did the following JNDI lookup:



It works fine, just got to get this working in Extended Search now, which is a bigger challenge!

Marc
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InitialContext - don't understand how to set this from an app not hosted by appserver