简体   繁体   English

JNDI 查找失败 websphere JRE1.8

[英]JNDI lookup fails websphere JRE1.8

I am migrating a legacy java/websphere application to JRE1.8我正在将遗留 java/websphere 应用程序迁移到 JRE1.8

JNDI lookup code (below) works fine in websphere8.5.5(JRE1.7) but throws Exception in websphere8.5.5(JRE1.8) JNDI 查找代码(下方)在 websphere8.5.5(JRE1.7) 中运行良好,但在 websphere8.5.5(JRE1.8) 中抛出异常

[Root exception is com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype]] [根异常是 com.ibm.websphere.naming.CannotInstantiateObjectException:在 JNDI NamingManager 处理 javax.naming.Reference object 时发生异常。[根异常是 javax.xml.parsers.FactoryDocumentFactoryError:提供者 javax.8883818.9763无法实例化:java.util.ServiceConfigurationError:javax.xml.parsers.DocumentBuilderFactory:提供商 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl 不是子类型]]

        javax.naming.InitialContext ctx = new javax.naming.InitialContext();
        ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/" + dsJNDIname);

I am sure, JNDI exists and valid.我确信,JNDI 存在并且有效。 I tried looking up "java:comp/env/" with below code, still fails with Exception " Name not found in context "java:". "我尝试使用以下代码查找“java:comp/env/”,但仍然失败并出现异常“在上下文“java:”中找不到名称。

        javax.naming.InitialContext ctx = new javax.naming.InitialContext();
        javax.naming.Context cxt = (javax.naming.Context) ctx.lookup("java:/comp/env/");

For the upgrade all I did was just rebuilding the source code in new workspace with JRE1.8.对于升级,我所做的只是使用 JRE1.8 在新工作区中重建源代码。 No code or config changes.没有代码或配置更改。 Not sure, if I would require changes to web.xml or ejb-jar.xml etc不确定,如果我需要更改 web.xml 或 ejb-jar.xml 等

Any suggestions appreciated.任何建议表示赞赏。

As suggested by F Rowe, the issue is because of some of the jars within source code which also came with websphere.正如 F Rowe 所建议的那样,问题是因为源代码中的一些 jars 也随 websphere 一起出现。 I was able to overcome the issue by changing the application classpath.我能够通过更改应用程序类路径来解决这个问题。

See IBM support doc https://www.ibm.com/support/pages/apar/PI79037 .请参阅 IBM 支持文档https://www.ibm.com/support/pages/apar/PI79037 You've likely got one or more jar files on the classpath that have versions of xerces that are conflicting with the IBM xml parser.您可能在类路径上有一个或多个 jar 文件,这些文件的 xerces 版本与 IBM xml 解析器冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM