troubleshooting Question

WAS5.x InitialContext issue

Avatar of vurity
vurity asked on
Java App Servers
3 Comments1 Solution734 ViewsLast Modified:

I am trying to do some lookups on the Websphere Appserver using the InitialContext and am getting the following Exception

Error : javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassCastException:]

The following is the code that I am using
Properties props = new Properties();
      props.put(Context.PROVIDER_URL, "iiop://localhost:26014/");
      // Create the initial context from the properties we just created
      Context initCtx= new InitialContext(props);

      out.println("initcontext: " + initCtx);
      System.out.println("initcontext: " + initCtx);
      Object o = initCtx.lookup("jdbc/somedatasource");
      out.println("object is:"+o);
      }catch(Exception e)
I am working on a Linux OS and this is the classpath for the appserver
ws.ext.dirs = /opt/WebSphere/AppServer/java/lib:/opt/WebSphere/AppServer/classes:/opt/WebSphere/AppServer/classes:/opt/WebSphere/AppServer/lib:/opt/WebSphere/AppServer/lib/ext:/opt/WebSphere/AppServer/web/help:/opt/WebSphere/AppServer/deploytool/itp/plugins/
Classpath = /opt/WebSphere/AppServer/properties:/opt/WebSphere/AppServer/properties:/opt/WebSphere/AppServer/lib/bootstrap.jar:/opt/WebSphere/AppServer/lib/j2ee.jar:/opt/WebSphere/AppServer/lib/lmproxy.jar:/opt/WebSphere/AppServer/lib/urlprotocols.jar
Java Library path = /opt/WebSphere/AppServer/java/bin/../jre/bin:/opt/WebSphere/AppServer/java/jre/bin/classic:/opt/WebSphere/AppServer/java/jre/bin:/usr/IBMdb2/V7.1/java12:/opt/WebSphere/AppServer/java/bin/../jre/bin:/opt/WebSphere/AppServer/java/jre/bin/classic:/opt/WebSphere/AppServer/java/jre/bin:/opt/WebSphere/AppServer/bin:/opt/mqm/java/lib:/opt/wemps/lib:/opt/WebSphere/AppServer/lib:/usr/lib

When I try the same code on my local WSAD it is working fine. I took care to change the port when I put it on the linux server, so that is taken care of.
Am I missing something in the classpath?

Thanks and Regards

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros