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 Problem with NamingContext in sessionClient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem with NamingContext in sessionClient" Watch "Problem with NamingContext in sessionClient" New topic
Author

Problem with NamingContext in sessionClient

saran sadaiyappan
Ranch Hand

Joined: Dec 23, 2004
Posts: 39
Hi,
I have written a client to call a session bean. I am loading the initial context and provider url as

-Djava.naming.factory.initial=org.jnp.interfaces.NamingContext
-Djava.naming.provider.url=http://localhost:8080

But I get a exception as,

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContext [Root exception is java.lang.InstantiationException: org.jnp.interfaces.NamingContext]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at slsb.CounterClient.main(CounterClient.java:30)

But I have loaded the jar file jnp-client.jar in the classpath. ANy idea why this happens?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Instead of using a -D command line option, why not include a jndi.properties file instead. Then let's go from there.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
saran sadaiyappan
Ranch Hand

Joined: Dec 23, 2004
Posts: 39
I dont think its related to reading them. But the problem is with loading them. Anyways I did it..still the same
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
read: http://www.coderanch.com/t/318695/EJB-JEE/java/First-Bean

You're right in setting commandline options but you're setting the wrong ones.
Setting properties inside the application is a bad idea, it makes your application too tightly linked with a specific server implementation and location.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with NamingContext in sessionClient