• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with NamingContext in sessionClient

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
read: https://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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic