Meaningless Drivel is fun!*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "NoClassDefFoundError exception in InitialContext()" Watch "NoClassDefFoundError exception in InitialContext()" New topic
Author

NoClassDefFoundError exception in InitialContext()

Henry Sun
Greenhorn

Joined: May 09, 2003
Posts: 18
Hi,
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, "com.ibm.websphere.naming.WsnInitialContextFactory");
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(Class.java:140)
at com.ibm.websphere.naming.WsnInitialContextFactory.init_implClassCtor(WsnInitialContextFactory.java:168)
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:108)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.allmedia.domain.util.JNDIInstaller.<init>(JNDIInstaller.java:39)
at com.allmedia.domain.util.JNDIInstaller.getInstnce(JNDIInstaller.java:46)
at com.allmedia.domain.facade.CategoryFacadeTest.<init>(CategoryFacadeTest.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:102)
at junit.framework.TestSuite.<init>(TestSuite.java:66)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:270)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:307)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)
)
at junit.framework.Assert.fail(Assert.java:51)
at junit.framework.TestSuite$1.runTest(TestSuite.java:225)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:329)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)
Can anyone help me figure it out?
Thanks!
henry
Venkateswara Rao Desu
Greenhorn

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/com.ibm.websphere.v61_6.1.0/
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
    
    1

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: http://aspose.com/file-tools
 
subject: NoClassDefFoundError exception in InitialContext()
 
Similar Threads
WSAD 5.0 EJB Client jndi lookup problem
MalformedURLException while testing Actionservlets
java.rmi.MarshalException
JUnit EJB problem
Jboss rar JNDI lookup