Xmlparserv2 error while application deployed in jb

2019-02-20 09:35发布

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]

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)

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

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?

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

2条回答
小情绪 Triste *
2楼-- · 2019-02-20 09:54

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

(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>

This worked :)

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)

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>

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

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.

查看更多
迷人小祖宗
3楼-- · 2019-02-20 10:04

Here's how I declare an Oracle datasource (for calling pl or executing xqueries)

Injecting the Datasource (in a stateless ejb)

@Resource(name = "java:jboss/datasources/xmlDatasource")
private DataSource productDS;

Declaring the datasource in standalone.xml

<datasource jndi-name="java:jboss/datasources/xmlDatasource" pool-name="xxx" enabled="true" use-java-context="true">
    <connection-url>jdbc:oracle:thin:@xxx:1521:xxx</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <driver>oracle</driver>
    <pool>
        <min-pool-size>0</min-pool-size>
        <max-pool-size>10</max-pool-size>
    </pool>
    <security>
        <user-name>xxx</user-name>
        <password>xxx</password>
    </security>
</datasource>
<drivers>
    <driver name="oracle" module="oracle.jdbc">
        <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
    </driver>
</drivers>

Module definition

<module xmlns="urn:jboss:module:1.1" name="oracle.jdbc">

    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>

Add the module dependency to my ear application (which has the stateless ejb inside..) using maven (or edit your manifest.mf and add the module name)

<archive>
    <manifestEntries>
        <Dependencies>oracle.jdbc</Dependencies>
    </manifestEntries>
</archive>
查看更多
登录 后发表回答