数据库
首页 > 数据库> > java-无法在Jboss EAP 7.0服务器中创建oracle数据源

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

作者:互联网

我需要在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部署是否正确?

解决方法:

将JDBC驱动程序安装为核心模块

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

示例Oracle JDBC驱动程序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驱动程序添加为核心模块.

模块添加–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(驱动程序名称= oracle,驱动程序模块名称= com.oracle,driver-xa-datasource-class-name = oracle.jdbc.xa.client.OracleXADataSource)

3#添加Oracle数据源.

数据源添加–name = OracleDS –jndi名称= java:jboss / OracleDS-驱动程序名称= oracle-连接URL = jdbc:oracle:thin:@localhost:1521:XE-用户名= admin –password = admin –validate-on-match = true –background-validation = false –valid-connection-checker-class-name = org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker –exception-sorter-class-name = org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter –stale-connection-checker-class-name = org.jboss.jca.adapters.jdbc.extensions.oracle .OracleStaleConnectionChecker

参考链接https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/version-7.0/configuration-guide/#datasource_management

标签:jboss,jboss7-x,java
来源: https://codeday.me/bug/20191111/2022998.html