作为部署安装时的 jboss-eap-6.1 oracle 驱动程序定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25687972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:29:54  来源:igfitidea点击:

jboss-eap-6.1 oracle driver definition when installed as deployment

javaoraclejdbcjboss

提问by MariusPontmercy

I have several Jboss EAP 6.1 installations working with Oracle driver installed as a module.

我有几个 Jboss EAP 6.1 安装与作为模块安装的 Oracle 驱动程序一起使用。

This is the standard configuration I use in standalone.xml:

这是我在 standalone.xml 中使用的标准配置:

<datasource jndi-name="java:jboss/fooDatasource" pool-name="java:jboss/fooDatasource" enabled="true" use-java-context="false" >
 <connection-url>jdbc:oracle:thin:@1.2.3.4:1527/SOMEDB.foo</connection-url>
 <driver>oracle</driver>
     <security>
         <user-name>xxxxx</user-name>
             <password>xxxxxxxxx</password>
     </security>
 [...]
</datasource>
<driver name="oracle" module="oracle.jdbc">
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
    <datasource-class>oracle.jdbc.OracleDriver</datasource-class>
</driver>

The ojdbc6.jar is in $JBOSS_HOME/modules/system/layers/base/oracle/jdbc/main/ together with the appropriate module.xml and everything works fine.

ojdbc6.jar 与相应的 module.xml 一起位于 $JBOSS_HOME/modules/system/layers/base/oracle/jdbc/main/ 中,一切正常。

Now a customer required to install the driver as a deployment, so I moved ojdbc6.jar to $JBOSS_HOME/standalone/deployments/ and I see from logs that it is deployed without errors:

现在客户需要安装驱动程序作为部署,所以我将 ojdbc6.jar 移动到 $JBOSS_HOME/standalone/deployments/ 并且我从日志中看到它部署没有错误:

[org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
INFO  [org.jboss.as.server] (ServerService Thread Pool -- 25) JBAS018559: Deployed "ojdbc6.jar" (runtime-name : "ojdbc6.jar")

But I don't know how to edit my standalone.xml to make it work again: i tried to edit the driver definition "module" attribute with several different values (ojdbc6.jar, deployment.ojdbc6.jar, oracle.jdbc.OracleDriver...) but none seem to "match" and Jboss keeps throwing errors at startup:

但我不知道如何编辑我的 standalone.xml 使其再次工作:我试图用几个不同的值(ojdbc6.jar、deployment.ojdbc6.jar、oracle.jdbc.OracleDriver)编辑驱动程序定义“模块”属性...)但似乎没有一个“匹配”并且 Jboss 在启动时不断抛出错误:

ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 24) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "oracle")
]) - failure description: "JBAS010441: Failed to load module for driver [ojdbc6.jar]"
[...]
INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
  service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.driver-demander.java:jboss/spiDatasource, service jboss.data-source.java:jboss/fooDatasource]

Could anyone please provide a working example of the driver definition?

任何人都可以提供驱动程序定义的工作示例吗?

Thanks

谢谢

回答by MariusPontmercy

Ok, I found the answer myself.

好的,我自己找到了答案。

Surprisingly, all the guides I found around explain how to do this configuration via web admin interface or via jboss-cli, but no one in the Jboss community seem to bother explaining how to manually edit the standalone.xml to do the job.

令人惊讶的是,我找到的所有指南都解释了如何通过 Web 管理界面或通过 jboss-cli 进行此配置,但 Jboss 社区中似乎没有人费心解释如何手动编辑 standalone.xml 来完成这项工作。

This is a working example (basically I just deletedthe entire Oracle driverdefinition section and replaced the driver name in the datasourcedefinition with the name of the runtime name of the deployed jar file):

这是一个工作示例(基本上我只是删除了整个 Oracle驱动程序定义部分,并将数据源定义中的驱动程序名称替换为已部署 jar 文件的运行时名称):

<datasource jta="false" jndi-name="java:/jdbc/fooDS" pool-name="foo-ds" use-ccm="false">
    <connection-url>jdbc:oracle:thin:@1.2.3.4:1527/SOMEDB.foo</connection-url>
    <driver-class>oracle.jdbc.OracleDriver</driver-class>
    <driver>ojdbc6.jar</driver>

    [...] other datasource stuff here

</datasource>

# DELETE FROM HERE...
<driver name="oracle" module="oracle.jdbc">
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
    <datasource-class>oracle.jdbc.OracleDriver</datasource-class>
</driver>
# ...TO HERE

That's all.

就这样。

回答by Vivek

Probably you have to mention in this way...

大概你要这样提...

<subsystem xmlns="urn:jboss:domain:datasources:1.1">
        <datasources>
            <datasource jndi-name="java:jboss/XXX" pool-name="XXX"     enabled="true" use-java-context="true">
                <connection-url>jdbc:oracle:thin:@SID:PORT:DBNAME</connection-url>
                <driver>oracle</driver>
                <security>
                    <user-name>user</user-name>
                    <password>password</password>
                </security>
            </datasource>
            <drivers>
                <driver name="oracle" module="com.oracle">
                    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    <datasource-class>oracle.jdbc.OracleDriver</datasource-class>
                </driver>
            </drivers>
        </datasources>
</subsystem>

回答by Deepu Surendran

  1. Create directories like x1/x2/main
  2. Create module.xml file under main directory
  3. Keep ojdbc6-11.1.1.3.0.jar in main directory level
  1. 创建像 x1/x2/main 这样的目录
  2. 在主目录下创建module.xml文件
  3. 将 ojdbc6-11.1.1.3.0.jar 保留在主目录级别

In Module.xml

在 Module.xml 中

<module xmlns="urn:jboss:module:1.1" name="x1.x2">
<properties>
    <property name="jboss.api" value="unsupported"/>
</properties>
<resources>
    <resource-root path="ojdbc6-11.1.1.3.0.jar"/>
</resources>
<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
</dependencies>

In domain.xml

在 domain.xml 中

<datasource jndi-name="java:/TestName" pool-name="TestName" enabled="true" use-java-context="true">
                    <connection-url>jdbc:oracle:thin:@ldap://xxxxx:3000/UKXXX,cn=OracleContext,dc=dcm,dc=XXXX</connection-url>
                    <driver>dps</driver>
                    <security>
                        <user-name>XXXXX</user-name>
                        <password>*****</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="dps" module="x1.x2">
                        <xa-datasource-class>oracle.jdbc.driver.OracleDriver</xa-datasource-class>
                    </driver>
                    </driver>
                </drivers>

Try to keep the correct ojdbc jar, some versions won't work :)

尝试保留正确的 ojdbc jar,某些版本将不起作用 :)