无法在Jboss EAP 7.0服务器

时间:2017-01-04 10:05:17

标签: java jboss jboss7.x

我需要在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部署,以便为数据源创建正确的方法?

1 个答案:

答案 0 :(得分:3)

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

  • 在$ JBOSS_HOME / modules下创建一个目录。在这个例子中:&#34; $ JBOSS_HOME / modules / com / oracle / jdbc / main&#34;。

  • 将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驱动程序添加为核心模块。

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

2#注册Oracle JDBC驱动程序。

/子系统=数据源/ JDBC驱动器=预言:添加(驱动程序名称=预言,驱动器模块名= com.oracle,驾驶员XA-数据源类名= oracle.jdbc.xa.client。 OracleXADataSource)

3#添加Oracle数据源。

data-source add --name = OracleDS --jndi-name = java:jboss / OracleDS --driver-name = oracle --connection-url = jdbc:oracle:thin:@localhost:1521:XE - user-name = 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