my dog learned polymorphism
The moose likes Websphere and the fly likes NoClassDefFoundError exception in InitialContext() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "NoClassDefFoundError exception in InitialContext()" Watch "NoClassDefFoundError exception in InitialContext()" New topic

NoClassDefFoundError exception in InitialContext()

Henry Sun

Joined: May 09, 2003
Posts: 18
I am writing a Java thin client in WSAD5 and testing with JUnit. Exception pops up when creating a context. The code is very simple:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "");
env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
initialContext = new InitialContext(env);
The exception message is:
junit.framework.AssertionFailedError: Exception in constructor: testFindCategory (java.lang.NoClassDefFoundError: com/ibm/CORBA/iiop/ObjectURL
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.init(
at javax.naming.InitialContext.<init>(
at com.allmedia.domain.util.JNDIInstaller.<init>(
at com.allmedia.domain.util.JNDIInstaller.getInstnce(
at com.allmedia.domain.facade.CategoryFacadeTest.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at junit.framework.TestSuite.addTestMethod(
at junit.framework.TestSuite.<init>(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
at junit.framework.TestSuite$1.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Can anyone help me figure it out?
Venkateswara Rao Desu

Joined: Apr 13, 2009
Posts: 7
This is because you didn't add ws_runtime.jar into your classpath.

Your classpath must contain ws_runtime.jar which will be available in %WEB_SPHERE_HOME%/Appserver/deploytool/itp/plugins/
This is specific to WAS 6.1. Check your WAS manual for respective runtime jar.

I think this solves your issue.

-- Venkateswara Rao Desu
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

I am writing a Java thin client in WSAD...

How 'thin' is your 'thin client?' Remember, anything with a main method will need to be run from a J2EE client container. The J2EE client container will have the appropriate JAR files needed by the WebSphere runtime.

If it's a Servlet, well, the point is moot.

-Cameron McKenzie
I agree. Here's the link:
subject: NoClassDefFoundError exception in InitialContext()
It's not a secret anymore!