Uncaught exception java.lang.NoClassDefFoundError

When I am trying to run the following code in Visual Age for Java.

Properties p = new Properties();

if (this.initialContext == null) {

try {

if (this.portNumber != null) {

String url =

"IIOP://" + this.hostName + ":" + this.portNumber + "/";

System.out.println("Using provider URL of: " + url);

p.put(javax.naming.Context.PROVIDER_URL, url);

}

p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,

"com.ibm.ejs.ns.jndi.CNInitialContextFactory");

this.initialContext = new InitialContext(p);

} catch (NamingException e) {

System.out.println("Exception Error-Initial Context");

}

}

This is giving an error as follows at line

this.initialContext = new InitialContext(p);

Could you please explain me how can get rid of this error... I am running the code on local machine in websphere test environment.

ERROR:--

Uncaught exception (java.lang.NoClassDefFoundError: javax.naming.InitialContext)

Client_1.getInitialContext()

this=(TestEJBGroupEJBReserved.Client_1) TestEJBGroupEJBReserved.Client_1@5312

p=(java.util.Properties) {java.naming.factory.initial=com.ibm.ejs.ns.jndi.CNInitialContextFactory, java.naming.provider.url=IIOP://localhost:8080/}

Client_1.main(String [])

args=([Ljava.lang.String;) [Ljava.lang.String;@3ffb

c1=(TestEJBGroupEJBReserved.Client_1) TestEJBGroupEJBReserved.Client_1@5312

[1515 byte] By [rittu_kumar] at [2007-9-26 2:56:31]
# 1

Hi rittu

I have answeredf for this question in another section.In case u haven't seen that i m posting the answers once again.

TRY IT!!!!!!!!!!!!!!!

Hope ur problem is in Visual Age settings for ur class.Basically it is not able to get com.ibm.ejs.ns.jndi.CNInitialContextFactory.For that do the foll steps.

1. Right click on ur class which is having ur code and click properties.Then Compute Now in Project Path.If it is still showing error means go to the second step

2. Click on the Edit button in the Project Path and then include IBM Websphere Test Environment in the Project Path

It will work

Pramod

pramod_bs at 2007-6-29 10:47:44 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...