在WildFly 8.2.0最终版本中添加模块

时间:2015-04-18 14:51:21

标签: java jboss derby wildfly wildfly-8

我是JBoss的新手,我尝试在WidlFly 8.2.0中为derby添加一个jdbc驱动程序。

我做了什么:

  • 我在JBOSS_HOME / modules / system / layers / base目录中添加了org / apache / derby / main文件夹
  • 在这个新文件夹中,我添加了derbyclient.jar(来自jdk 1.8.0_40,它包含驱动程序)和一个新的module.xml文件。

module.xml文件如下:

 <?xml version="1.0" encoding="UTF-8"?>
 <module xmlns="urn:jboss:module:1.0" name="org.apache.derby">
     <resources>
         <resource-root path="derbyclient.jar"/>
     </resources>
     <dependencies>
         <module name="javax.api"/>
     </dependencies>
 </module>

然后,我更新了standalone.xml文件,如下所示:

  • 添加此标记(<extensions>):<extension module="org.apache.derby"/>

声明我的数据源和驱动程序:

<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS" enabled="true" use-ccm="false">
    <connection-url>jdbc:derby:MyDB;create=true</connection-url>
    <driver>org.apache.derby</driver>
    <security>
        <user-name>demo</user-name>
         <password>demo</password>
    </security>
    <validation>
        <validate-on-match>false</validate-on-match>
        <background-validation>false</background-validation>
    </validation>
    <statement>
        <share-prepared-statements>false</share-prepared-statements>
    </statement>
</datasource>
<drivers>
    <driver name="org.apache.derby" module="org.apache.derby">
        <xa-datasource-class>org.apache.derby.jdbc.ClientXADataSource</xa-datasource-class>
    </driver>
    <driver name="h2" module="com.h2database.h2">
        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
</drivers>

启动WildFly时出现以下错误:

`16:19:49,856 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "DerbyDS")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
    "jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
    "jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
]}
16:19:49,866 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "DerbyDS")
]) - failure description: {
    "JBAS014771: Services with missing/unavailable dependencies" => [
        "jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
        "jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
    ],
    "JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
        "Services that were unable to start:" => [
            "jboss.data-source.reference-factory.DerbyDS",
            "jboss.naming.context.java.DerbyDS"
        ],
        "Services that may be the cause:" => ["jboss.jdbc-driver.org_apache_derby"]
    }
}
16:19:49,897 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp.ear" (runtime-name : "MyApp.ear")
16:19:49,897 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp2.ear" (runtime-name : "MyApp2.ear")
16:19:49,907 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.org_apache_derby (missing) dependents: [service jboss.driver-demander.java:/DerbyDS, service jboss.data-source.java:/DerbyDS]`

你知道我做错了什么吗?

提前致谢

2 个答案:

答案 0 :(得分:1)

我终于解决了这个问题:

  • 在独立目录(部署我的应用程序)中添加derbyclient.jar
  • 修改standalone.xml中的数据源声明,使其引用jar名称:

<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS"enabled="true" use-ccm="false"> <connection-url>jdbc:derby:MyDB;create=true</connection-url> <driver>derbyclient.jar</driver>...

(我删除了<drivers>标记,我不再使用它了。)

因此,当我启动WildFly时,我不再有错误。德比驱动程序未被声明为模块,但它将在我的不同应用程序之间共享,因此可以。

答案 1 :(得分:0)

您的网址jdbc:derby://:MyDB看起来无效。