无法在 Wildfly 10 上定义 oracle 数据源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40761736/
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 03:20:04  来源:igfitidea点击:

Unable to define oracle datasource on Wildfly 10

oraclejbossdatasourcewildflywildfly-10

提问by Ena Jovicic

I'm using wildfly-10.1.0.Final and I'm trying to add an oracle Datasource:

我正在使用 wildfly-10.1.0.Final 并且我正在尝试添加一个 oracle 数据源:

<datasource jndi-name="java:jboss/datasources/OracleDS" pool-name="OracleDS" enabled="true">
                <connection-url>jdbc:oracle:thin:@localhost:1523/pdborcl</connection-url>
                <driver>oracle</driver>
                <pool>
                    <min-pool-size>1</min-pool-size>
                    <max-pool-size>5</max-pool-size>
                    <prefill>true</prefill>
                </pool>
                <security>
                    <user-name>admin</user-name>
                    <password>admin</password>
                </security>
            </datasource>

And the driver:

还有司机:

    <driver name="oracle" module="com.oracle.ojdbc">
                    <driver-class>oracle.jdbc.OracleDriver</driver-class>
                </driver>

I have a module under modules/com/oracle/ojdbc/main:

我在 modules/com/oracle/ojdbc/main 下有一个模块:

<module xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc">
  <resources>
    <resource-root path="ojdbc7.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

But when I start the server I get:

但是当我启动服务器时,我得到:

11:14:30,226 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "OracleDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.oracle"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.oracle]",
        "jboss.driver-demander.java:jboss/datasources/OracleDS is missing [jboss.jdbc-driver.oracle]"
    ]
}
11:14:30,228 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "OracleDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.oracle",
        "jboss.jdbc-driver.oracle"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.oracle]",
        "jboss.driver-demander.java:jboss/datasources/OracleDS is missing [jboss.jdbc-driver.oracle]",
        "org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.oracle]"
    ]

I already read all the similar threads, including this one: Unable to define oracle datasource on Jboss AS 7. But, I couldn't seem to find the solution.

我已经阅读了所有类似的线程,包括这个:Unable to define oracle datasource on Jboss AS 7。但是,我似乎找不到解决方案。

回答by Silvio Silva

Another way to do that:

另一种方法:

Log on WildFly CLI

登录 WildFly CLI

./jboss-cli.sh -c

Deploy the Oracle JDBC Driver

部署 Oracle JDBC 驱动程序

deploy /path_to_the_file/ojdbc7.jar

Creates a JDBC Data Source with one Connection Pool Configured

创建一个配置了一个连接池的 JDBC 数据源

data-source add \
--name=MyOracleDataSource \
--jndi-name=java:/datasources/MyOracleDataSource \ 
--driver-name=ojdbc7.jar \ 
--driver-class=oracle.jdbc.OracleDriver \ 
--connection-url=jdbc:oracle:thin:@ORACLE_SERVER_NAME:1521/ORACLE_SERVICE_NAME \ 
--user-name=ORACLE_USER_NAME \ 
--password=ORACLE_USER_PASSWORD \ 
--allocation-retry=3 \ 
--background-validation=true \ 
--background-validation-millis=60000 \ 
--capacity-incrementer-class=org.jboss.jca.core.connectionmanager.pool.capacity.WatermarkIncrementer \ 
--capacity-decrementer-class=org.jboss.jca.core.connectionmanager.pool.capacity.WatermarkDecrementer \ 
--check-valid-connection-sql='SELECT 1 FROM dual' \ 
--connectable=false \ 
--enlistment-trace=true \ 
--exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter \ 
--flush-strategy=EntirePool \ 
--jta=true \ 
--initial-pool-size=2 \ 
--min-pool-size=2 \ 
--max-pool-size=5 \ 
--mcp=org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool \ 
--pool-prefill=true \ 
--pool-use-strict-min=true \ 
--set-tx-query-timeout=false \ 
--share-prepared-statements=false \ 
--spy=false \ 
--stale-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker \ 
--statistics-enabled=true \ 
--track-statements=NOWARN \ 
--tracking=false \ 
--use-ccm=true \ 
--use-fast-fail=false \ 
--use-java-context=true \ 
--valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker \ 
--enabled=true

回答by cljk

As stated in my comment above I had and have the same problem - my driver-modules working on Wildfly 8 were not working under wildfly 10.

正如我在上面的评论中所述,我遇到了同样的问题 - 我在 Wildfly 8 上工作的驱动程序模块在 Wildfly 10 下无法工作。

I now have a workaround(/solution?) - see https://docs.jboss.org/author/display/WFLY10/DataSource+configuration:

我现在有一个解决方法(/解决方案?) - 请参阅https://docs.jboss.org/author/display/WFLY10/DataSource+configuration

I simply deployed the ojdbc7.jar like I would do with an EAR or WAR (used the admin frontend http://localhost:9990).

我只是像使用 EAR 或 WAR 一样部署了 ojdbc7.jar(使用管理前端http://localhost:9990)。

My server then recognized the driver

我的服务器然后识别了驱动程序

WFLYJCA0004: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 12.1) Started Driver service with driver-name = ojdbc7-12.1.0.1.jar

WFLYJCA0004:部署符合 JDBC 的驱动程序类 oracle.jdbc.OracleDriver(版本 12.1)使用驱动程序名称 = ojdbc7-12.1.0.1.jar 启动驱动程序服务

and I could define a Non-XA datasource (Configuration -> Subsystems -> Datasources) and it worked. I reallydon′t know if this deployment has any drawbacks. But my arquillian test cases seem to work.

我可以定义一个非 XA 数据源(配置 -> 子系统 -> 数据源)并且它工作正常。我真的不知道这种部署是否有任何缺点。但是我的 arquillian 测试用例似乎有效。

In wildfly 10 I don′t see any possibilities to edit my existing datasource and the server asks me to restart on every configuration change.... Even configuration options for validating the connection etc. are missing in admin gui?!

在wildfly 10 中,我看不到任何编辑现有数据源的可能性,并且服务器要求我在每次配置更改时重新启动.... admin gui 中甚至缺少用于验证连接等的配置选项?!