Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI InitialContext Lookup Exception

 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I created a EAR project and an application Client project using RAD 7.5. Client project has been included as a module in EAR. The client project has Main.java (Standalone class).

RAD7.5 has been configured to use local WAS6.0 test environment. JMS resources have been configured in WAS6.0 test environment and SI bus has already been created in WAS. My final goal is to send a message to SI bus queue using Main.java class. But I am getting the below exception during InitialContext lookup itself.

Exception in RAD7.5 console is below:

InitialContext starts....
Aug 11, 2010 10:07:46 PM com.ibm.ws.naming.util.CommonHelpers
WARNING: jndiproviderProperties
Aug 11, 2010 10:07:47 PM com.ibm.ws.naming.util.CommonHelpers
WARNING: jndiproviderProperties
Aug 11, 2010 10:07:47 PM com.ibm.websphere.naming.WsnInitialContextFactory
WARNING: noInitCtxFactoryImpl
Exception in thread "main" javax.naming.ConfigurationException: The property com.ibm.ws.naming.wsn.factory.initial is not set. The most likely cause is that the jar which contains the file com/ibm/websphere/naming/jndiprovider.properties cannot be found by the class loader.
at com.ibm.websphere.naming.WsnInitialContextFactory.init_implClassCtor(WsnInitialContextFactory.java:194)
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:112)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:675)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:257)
at javax.naming.InitialContext.init(InitialContext.java:233)
at javax.naming.InitialContext.<init>(InitialContext.java:209)
at sender.Main.main(Main.java:29)


Main.java class snippet is below:


I see, Provider URL value as "iiop://localhost:21005/" in Universal Test Client GUI in RAD. RAD uses the default jdk which comes in RAD v7.5. Please help to troubleshoot what is causing this error?. I googled it, but couldn't find the cause. Thanks
 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try using following format of provider URL and post your findings? Generally the boot strap address is 2809.


 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with below options, getting the same exception.






Perhaps, I never changed port number after WAS installation, so, the default port should be 2809 for corbaloc. Where can I look for the port number? Am I missing something else?
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to find the port numbers in WAS under "Servers -> Application servers -> [server1] -> Configuration -> Ports"
 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The configured port numbers are below. Here the BOOTSTRAP_ADDRESS port# is 21005. I already tried with this port

Port Name Port


 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your problem is related to classpath. The client application which is trying to do the JNDI lookup is not able to locate the initial context factory class in its classpath. Fix the classpath and you should be all set.
 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm able to access InitialContextFactory in Main.java (Client) class, also Websphere lib files have been included in the class path. So, don't see any classpath issue for InitialContextFactory class. any other clue?
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using an IBM jdk on the client too ??
 
Claude Moore
Ranch Hand
Posts: 814
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Pant wrote:I think your problem is related to classpath. The client application which is trying to do the JNDI lookup is not able to locate the initial context factory class in its classpath. Fix the classpath and you should be all set.


I agree. Time ago, I encountered the same problem, I included some jars of WAS runtime (I just don't rember which ) and the issue has been fixed.
By the way, I remember that those jars were not lightweight... moreover, I was not sure that I could redistribuite them with my application, so I gave up
and searched for another solution....

 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using IBM JDK
 
Viji San
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try to add the jars mentioned in the below thread and test it.
http://www.coderanch.com/t/74068/Websphere/Jars-required-run-stanalone-application
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic