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

后端 未结 2 1452
一整个雨季
一整个雨季 2021-01-16 09:20

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

相关标签:
2条回答
  • 2021-01-16 09:54

    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>
    
    0 讨论(0)
  • 2021-01-16 10:05

    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.

    0 讨论(0)
提交回复
热议问题