Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the InitialContextFactory with Sun App Server

Status
Not open for further replies.

brinker

Programmer
May 31, 2001
48
CA
Hello everyone,

I have been a long time member of tek-tips, but am fairly new to the J2EE forum.

I am trying to access a Java bean deployed using Sun Application server from outside the container (ie. an external client Java program). There are no jsp pages, just an application client and 1 bean (with home, object, and bean components) The code I am using is below, but it does not seem to work:

InitialContext initialContext = new InitialContext();
String url = "rmi://localhost";
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
p.put(Context.PROVIDER_URL, url);
ctx = new InitialContext(p);

// lookup InterestCalculator EJB
Object homeObject =
initialContext.lookup( "java:comp/env/ejb/InterestCalculator");


I was wondering if anybody has a solution to this problem or could provide me with some code.

thanks

Narjit
 
errors ?

You say you are using the "Sun App Server" - is this the J2EE RI version ? JNDI lookups tend to be vendor specific, and also, in the past I find the java:comp/env var/dir is unforgiving - try leaving it out ...
 
Thanks for the reply.

I believe the first problem is with the "com.sun.enterprise.naming.SerialInitContextFactory" not being able to be fournd. I believe this is right as I got the code from Sun's web site. Do you know if I need to import anything to get this piece of code to work. I am using a client program to call the beans from outside the container.

thanks
 
Have you got the J2EE_HOME/lib/j2ee.jar on your CLASSPATH ?

Post the specific error too ...
 
Yes, the j2ee.jar is definitely in the classpath. The exception I am getting is :

javax.naming.noInitialContextException
cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory

I know that this class cannot be found, but I do not know why or how to solve this problem.
 
Thanks for the article. I'm still combing through it and will let you know if I can figure out something from it.
 
No success.

It appears as if com.sun.enterprise.naming.SerialInitContextFactory cannot be found. I am curious as whether I am missing something. The container the application is running in on Sun's deployment server is different from the program that the client is using.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top