Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with NamingContext in sessionClient

 
saran sadaiyappan
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using a -D command line option, why not include a jndi.properties file instead. Then let's go from there.

Mark
 
saran sadaiyappan
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic