无法在Jboss EAP 7.0服务器中创建oracle数据源

fjaof16o  于 2023-08-05  发布在  Oracle
关注(0)|答案(1)|浏览(129)

我需要在JBOSS EAP 7.0服务器中创建Oracle数据源
我使用以下命令从JBOSS管理CLI(命令行界面)部署了ojdbc6.jar

deploy <PATH_TO_ORACLE_DRIVER_JAR>

字符串
我可以看到服务器日志如下后,驱动程序部署

01:25:53,338 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = ojdbc6.jar
01:25:53,747 INFO  [org.jboss.as.server] (management-handler-thread - 6) WFLYSRV0010: Deployed "ojdbc6.jar" (runtime-name : "ojdbc6.jar")


但是当我尝试从Jboss管理控制台创建oracle数据源(oracle.jdbc.driver.OracleDriver作为驱动程序类)时,我得到下面的错误

01:31:35,084 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 66) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "OracleDS")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "jboss.driver-demander.java:/OracleDS is missing [jboss.jdbc-driver.oracle]",
    "org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.oracle]"
]}
01:31:35,092 INFO  [org.jboss.as.controller] (ServerService Thread Pool -- 66) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.data-source.reference-factory.OracleDS (missing) dependents: [service jboss.naming.context.java.OracleDS]
      service jboss.data-source-config.OracleDS (missing) dependents: [service org.wildfly.data-source.OracleDS]
      service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.driver-demander.java:/OracleDS, service org.wildfly.data-source.OracleDS]


1)我可以知道是什么原因导致这个问题吗?缺少什么依赖性?
2)安装JDBC驱动程序作为JAR部署以创建数据源的方法正确吗?

rqqzpn5f

rqqzpn5f1#

安装JDBC驱动作为核心模块

  • 在$JBOSS_HOME/modules下创建一个目录。在本示例中:“$JBOSS_HOME/modules/com/oracle/jdbc/main”。
  • 将JDBC驱动程序jar(ojdbc6.jar)放在这个目录中。
  • 创建一个模块配置文件module.xml:

Oracle JDBC Driver module.xml文件示例

<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

字符串

Oracle数据源配置示例

<datasources>
  <datasource jndi-name="java:jboss/OracleDS" pool-name="OracleDS">
    <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
    <driver>oracle</driver>
    <security>
        <user-name>admin</user-name>
        <password>admin</password>
    </security>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
        <validate-on-match>true</validate-on-match>
        <background-validation>false</background-validation>
        <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
    </validation>
  </datasource>
  <drivers>
    <driver name="oracle" module="com.oracle">
        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
    </driver>
  </drivers>
</datasources>

管理CLI命令示例

此示例配置可通过使用以下管理CLI命令来实现。

1.添加Oracle JDBC驱动作为核心模块。

模块add --name=com.oracle --resources=/path/to/misc/jdbc_drivers/oracle/ojdbc7.jar --dependencies=javax.API,javax.transaction.api

2.注册Oracle JDBC驱动。

/subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

3.添加Oracle数据源。

data-source add --name=OracleDS --jndi-name=java:jboss/OracleDS --driver-name=oracle --connection-url=jdbc:Oracle:薄:@localhost:1521:XE --user-name=admin --password=admin --validate-on-match=true --background-validation=false --valid-connection-checker-class-name=org。jboss。JCA适配器jdbc扩展。OracleOracleValidConnectionChecker --exception-sorter-class-name=org。jboss。JCA适配器jdbc扩展。OracleOracleExceptionSorter--stale-connection-checker-class-name=org。jboss。JCA适配器jdbc扩展。OracleOracleStaleConnectionChecker
请参考链接https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/version-7.0/configuration-guide/#datasource_management

相关问题