Xmlparserv2 error while application deployed in jboss, Installing Oracle ojdbc module in JBoss for Java web application
Asked Answered
G

2

1

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

Gallinule answered 14/10, 2014 at 21:2 Comment(6)
Are you deploying your oracle driver inside the war? If that is the case, I would define a jboss module to place the oracle driver (I believe is the standard way to deploy database drivers), and remove it from your war libCourtund
yes, I am packaging xdb.jar, ojdbc.jar and xmlparserv2.jar as part of war. Appreciate that suggestion. I found another reference similar to what you say. lemme try that and get back to this.. Thanks .. developer.jboss.org/thread/216216?tstart=0Gallinule
another reference with no solution: community.oracle.com/message/10321718Gallinule
another reference-issue with 11g driver - aquaclusters.com/app/home/project/public/aquadatastudio/issue/…Gallinule
I didn't have any datasource. I connect to the database directly by loading the driver, and getting connection . DriverManager.registerDriver(new OracleDriver()); conn = DriverManager.getConnection(DB_CONNECTION_URL);Gallinule
Driver manager loads any available driver on classpath.. I am trying on setting default driver, and also to set the datasourceGallinule
G
1

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.

Gallinule answered 20/10, 2014 at 21:25 Comment(0)
C
1

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>
Courtund answered 20/10, 2014 at 16:44 Comment(7)
Good luck, hope it helps!Courtund
Tried your initial comment: ie: the initial step of marking the driver as a dependency in MANIFEST.MF ; and creating the module.xml inside /opt/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. This alone addressed the issue. I will add the details as a seperate answer, but yours would be the accepted one. you deserve the bounty for the real help. Will accept the answer after trying out the datasource, I am sure its right, thoughGallinule
Please note that I didn't remove the ojdbc.jar from the war file thoughGallinule
Thank you very much, so glad it helped!! Consider removing the jar from your war, It could be trouble! I´m pretty sure you don´t need it inside your lib folder, just let the module do the work :)Courtund
haha sure :) done, adding as answer, rather than updating the questionGallinule
updated my answer with a note stating removing the jar , will prevent it form running succesfully in tomcat server.Gallinule
Yes, your comment is correct, remove only for jbossCourtund
G
1

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.

Gallinule answered 20/10, 2014 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.