在 jboss 中部署应用程序时出现 Xmlparserv2 错误,在 JBoss 中为 Java Web 应用程序安装 Oracle ojdbc 模块 [英] Xmlparserv2 error while application deployed in jboss, Installing Oracle ojdbc module in JBoss for Java web application

查看:31
本文介绍了在 jboss 中部署应用程序时出现 Xmlparserv2 错误,在 JBoss 中为 Java Web 应用程序安装 Oracle ojdbc 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考此 SO 线程 - Java:从 StoredProcedure 返回 XMLType 数据,ojdbc6 的使用.jar xdb6.jar xmlparserv2.jar 用于 Java 到 PLSQL 交互[ojdbc6.jar、xdb6.jar、xmlparserv2-11.1.1.jar]

Referring to this SO thread - Java: Returning XMLType Data from StoredProcedure, Usage of ojdbc6.jar xdb6.jar xmlparserv2.jar for Java to PLSQL interaction [ojdbc6.jar, xdb6.jar, xmlparserv2-11.1.1.jar]

当应用程序部署在安装了 JDK1.6 的 PC 上的本地 tomcat 服务器中时,该应用程序运行良好[能够毫无异常地检索数据,但是当部署在运行 JDK 1.7 的 JBOSS EAP 6.2 服务器中时,它抛出尝试通过 OJDBC 桥检索 XML 时出现异常.

The application works perfectly[able to retrieve the data without any exceptions] when it is deployed in my local tomcat server on my PC with JDK1.6 installed, but when deployed in JBOSS EAP 6.2 server running with JDK 1.7, it throws exception when trying to retrieve the XML through the OJDBC bridge.

java.lang.NullPointerException
13:53:51,265 ERROR [stderr] (http-/0.0.0.0:8080-1)  at oracle.jdbc.driver.NamedTypeAccessor.getOracleObject(NamedTypeAccessor.java:320)
13:53:51,268 ERROR [stderr] (http-/0.0.0.0:8080-1)  at oracle.jdbc.driver.NamedTypeAccessor.getObject(NamedTypeAccessor.java:217)
13:53:51,270 ERROR [stderr] (http-/0.0.0.0:8080-1)  at oracle.jdbc.driver.NamedTypeAccessor.getObject(NamedTypeAccessor.java:123)
13:53:51,273 ERROR [stderr] (http-/0.0.0.0:8080-1)  at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:2049)
13:53:51,275 ERROR [stderr] (http-/0.0.0.0:8080-1)  at oracle.jdbc.driver.OracleCallableStatementWrapper.getObject(OracleCallableStatementWrapper.java:818)

我尝试更改本地编译器设置并将 JRE 从 1.6 安装到 1.7,但本地仍然运行良好.

I tried changing my local compiler settings and installed JRE from 1.6 to 1.7, still the local runs good.

请在此错误上提出您的意见,我在远程 PC 上的 JBOSS 服务器上遇到此错误.JBOSS 是否试图覆盖我已经放在应用程序 war 文件中的 ojdbc jar?

Please throw your inputs on this error I am getting on the JBOSS server in remote PC. Is JBOSS trying to override the ojdbc jar that I already put in the application war file?

更新:将安装 JBoss 的远程服务器中的 JDK 版本从 1.7 降级到 1.6.在 JBoss 服务器中运行时仍然出现此错误.寻找可能遇到此问题或知道此问题原因的人.请分享您的意见

updates: Downgraded the JDK version from 1.7 to 1.6 in the remote server where JBoss is installed. Still getting this error while running in JBoss server. Looking for someone who might have came across this problem or knows what is the reason for this issue. Please share your inputs

推荐答案

我没有编辑问题,而是添加了对我的案例有效的答案;感谢@mendieta

Instead of editing the question, I am adding as answer as to what worked in my case; Kudos to @mendieta

(1)我尝试在 MANIFEST.MF [Dependencies: com.oracle] 中将驱动程序标记为依赖项;并在 /jboss/jboss-eap-6.2/modules/system/layers/base/com/oracle/main 中创建 module.xml并将 module.xmlojdbc6.jar 放在 main 目录中.

(1) I tried marking driver as a dependency in MANIFEST.MF [Dependencies: com.oracle] ; and creating the module.xml inside /jboss/jboss-eap-6.2/modules/system/layers/base/com/oracle/main and placing both module.xml and the ojdbc6.jar inside the main directory.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.oracle">
    <resources>
        <resource-root path="ojdbc6-11.2.0.4.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>

这行得通:)

因此问题在于引用正确的 jdbc 驱动程序.Tomcat可以[可能tomcat有jdbc(?)的版本],jetty可以,但是jboss需要这种方式安装jdbc驱动.

hence issue was with referring the correct jdbc driver. Tomcat could[probably tomcat has its version of jdbc(?)], jetty could, but jboss need this way of installing the jdbc driver.

(2)

pom.xml 中添加以下条目以在创建 war 文件时添加清单条目,并排除 ojdbc.jar 来自清单类路径(如果您将类路径设置为 true,我没有)并从 WEB-INF/lib

Added the following entries in pom.xml to add the manifest entry while creating the war file, and also to exclude the ojdbc.jar from the manifest classpath(if you set classpath true, I did not) and to exclude from WEB-INF/lib

 <build>
       <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Dependencies>com.oracle</Dependencies>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

       </plugins>

    </build>



<dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc6</artifactId>
                <version>11.2.0.4</version>
                <!-- excluded from manifest classpath, and excluded from WEB-INF/lib -->
                <scope>provided</scope>
            </dependency>

maven pom.xml 的参考:http://maven.apache.org/guides/mini/guide-archive-configuration.html

References for maven pom.xml : http://maven.apache.org/guides/mini/guide-archive-configuration.html

注意: 从 war 文件中删除 ojdbc.jar 可能会阻止应用程序在 tomcat 服务器中运行.假设它会在 jboss 服务器中运行,它已从战争中删除,我们已经将驱动程序安装为 jboss 模块.

note: Removing the ojdbc.jar from war file might prevent the application from running in tomcat server. It's removed from the war assuming its gonna run in jboss server, where we already installed the driver as a jboss module.

这篇关于在 jboss 中部署应用程序时出现 Xmlparserv2 错误,在 JBoss 中为 Java Web 应用程序安装 Oracle ojdbc 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆