How to solve sun/io/MalformedInputException during JNDI lookup on remote WebSphere

10.2k views Asked by At

I use WebSphere 8.5 to host my application and configured some JDBC resources on the application server. Also I developed a client application using the thin client runtime library. When the JNDI look-up is performed in the following manner:

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "corbaloc:iiop:serv:2809");
Context initialContext = new InitialContext(env);
DataSource ds = (DataSource) initialContext.lookup("cell/node/servers/server/MYDB");

the following exception is raised:

java.lang.NoClassDefFoundError: sun/io/MalformedInputException
at com.ibm.rmi.iiop.CDRReader.getTcsCConverter(CDRReader.java:451)
    at com.ibm.rmi.iiop.CDRReader.readStringOrIndirection(CDRReader.java:532)
    at com.ibm.rmi.iiop.CDRReader.read_string(CDRReader.java:518)
    at com.ibm.rmi.IOR.read(IOR.java:337)
    at com.ibm.rmi.iiop.Connection._locate(Connection.java:531)
    at com.ibm.rmi.iiop.Connection.locate(Connection.java:490)
    at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:229)
    at com.ibm.rmi.corba.Corbaloc.locateUsingINS(Corbaloc.java:307)
    at com.ibm.rmi.corba.Corbaloc.resolve(Corbaloc.java:378)
    at com.ibm.rmi.corba.ORB.objectURLToObject(ORB.java:3796)
    at com.ibm.CORBA.iiop.ORB.objectURLToObject(ORB.java:3263)
    at com.ibm.rmi.corba.ORB.string_to_object(ORB.java:3694)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.stringToObject(WsnInitCtxFactory.java:1645)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getWsnNameService(WsnInitCtxFactory.java:1502)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:1040)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:962)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:614)
    at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128)
    at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at ch.bit.easy.wf.util.Database.getConnection(Database.java:74)
    at ch.bit.easy.wf.ops.test.TestDBAccess.testSuccessfullyLimitedQuery(TestDBAccess.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: sun.io.MalformedInputException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
2

There are 2 answers

0
ParanoidUser On BEST ANSWER

If you wanna use Oracle JDK 8.0 with IBM Websphere, try to replace 'ibmorb.jar' in your classpath to a newer (that using new java.nio.charset.MalformedInputException class).

You can find it here:

  1. Download IBM JDK 8.0 (https://www.ibm.com/developerworks/java/jdk/java8/);
  2. Unzip obtained archive into a folder (eclipseDevelopmentPackage by default);
  3. Copy 'ibmorb.jar' from the following path: /eclipseDevelopmentPackage/ibm_sdk80/jre/lib/ibmorb.jar

Hope these help.

0
Haribabu On

In case of Sterling Commerce agents(Sterling 9.5 with JDK 8), you may get the below exception while starting the agent/Integration Servers.

cause : In JDK 8 , MalformedInputException was moved to another package and sterling still expecting in the same packance throwing this error.

*

Caused by: java.lang.NoClassDefFoundError: sun/io/MalformedInputException
        at com.ibm.rmi.iiop.CDRReader.getTcsCConverter(CDRReader.java:451)
        at com.ibm.rmi.iiop.CDRReader.readStringOrIndirection(CDRReader.java:532)
        at com.ibm.rmi.iiop.CDRReader.read_string(CDRReader.java:518)
...
Caused by: java.lang.ClassNotFoundException: sun.io.MalformedInputException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:353)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 34 more

*

Solution : Take the rt.jar from previous java versions(1.6 or 1.7) where sun.io.MalformedInputException is still in the same package as sterling expects and do the Thirdparty installation of the jar.

It works :)