当前位置: 首页 > 面试题库 >

如何在远程WebSphere上的JNDI查找期间解决sun / io / MalformedInputException

仇正豪
2023-03-14
问题内容

我使用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)

问题答案:

如果要在IBM Websphere上使用Oracle JDK 8.0,请尝试将类路径中的“
ibmorb.jar”替换为较新的类(使用新的java.nio.charset.MalformedInputException类)。

你可以在这里找到它:

  1. 下载IBM JDK 8.0(https://www.ibm.com/developerworks/java/jdk/java8/);
  2. 将获得的存档解压缩到一个文件夹中(默认情况下为eclipseDevelopmentPackage);
  3. 从以下路径复制“ ibmorb.jar”:/eclipseDevelopmentPackage/ibm_sdk80/jre/lib/ibmorb.jar

希望这些帮助。



 类似资料:
  • 在查找jdbc数据源的JNDI连接时,我遇到以下错误: javax。命名。ConfigurationException:无法完成“java:”名称上的JNDI操作,因为服务器运行时无法将该操作的线程与任何J2EE应用程序组件关联。当使用“java:”名称的JNDI客户端未在服务器应用程序请求的线程上执行时,可能会出现这种情况。确保J2EE应用程序不会在静态代码块或该J2EE应用程序创建的线程中对“

  • 我对JavaEE非常陌生,尝试运行一个小的EJB示例,但远程JNDI查找总是失败。 到目前为止,我做了什么? 我使用Eclipse for JavaEE,在Marketplace上安装了JBossTools并创建了一个JBoss EAP 7. x运行时服务器(我在安装过程中下载了一个7.1运行时)。 我写了一些Bean,将它们部署在服务器上并启动它。 我用JNDI-Lookup编写了一些客户端代码

  • 我在本地机器上创建了两个liberty实例。我在服务器X中部署了一个包含远程ejb的war模块,并在服务器Y中部署了另一个war模块,它必须从服务器X中远程查找ejb。 下面是从宁静的 Web 服务中查找 ejb 的代码。 当我尝试调用 Web 服务时,我得到以下异常 本地对象不支持 DII 操作 P.S.我已经在两个端口号不同的服务器上启用了ejbRemote功能。 我将查找字符串更改为“cor

  • 我试图从运行在WebSphere7上的web应用程序中调用SAP web服务。 客户机是从WSDL生成的,我使用JNDI查找来查找服务。查找失败,出现。 网状物xml: JNDI查找: 例外情况: 我已经使用来显示所有的名称,但是我看不到。 有许多JDBC资源也可以通过JNDI访问。这些在垃圾堆中可见,工作正常。 我忘了什么吗?

  • 我们目前正在开发一个部署在WebSphere服务器上的应用程序。该应用程序应该使用内部服务提供者,该服务提供者提供对作为远程EJB实现的服务的访问。服务提供者bean有一些硬编码的jndi名称可供使用。 现在在开发过程中,我们正在使用Tomee,总的来说一切都运行良好。除了一件事:ServiceProvider对“cell/持久/confiService”进行jndi查找。现在我尝试创建一个包含这

  • 我在我的应用程序中使用EJB3.1。 我想在我的应用程序中将一个EJB的JNDI查找名称发送到另一个应用程序,以便它可以在运行时使用它 用程序找出任意EJB的查找名的过程是什么?