我使用WebSphere 8.5来托管我的应用程序并在应用程序服务器上配置了一些JDBC资源.
我还使用瘦客户端运行时库开发了一个客户端应用程序.
以下列方式执行JNDI查找时:
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");
引发以下异常:
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)
解决方法:
如果您想将Oracle JDK 8.0与IBM Websphere一起使用,请尝试将类路径中的“ibmorb.jar”替换为更新的(使用新的java.nio.charset.MalformedInputException类).
你可以在这里找到它:
>下载IBM JDK 8.0(https://www.ibm.com/developerworks/java/jdk/java8/);
>将获取的存档解压缩到一个文件夹中(默认情况下为eclipseDevelopmentPackage);
>从以下路径复制’ibmorb.jar’:/eclipseDevelopmentPackage/ibm_sdk80/jre/lib/ibmorb.jar
希望这些帮助.