在 WildFly 8.2.0 Final 版本中添加模块

Adding a module in WildFly 8.2.0 Final release

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

我做了什么:

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 文件如下:

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

<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]`

你知道我做错了什么吗?

提前致谢

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

我终于解决了这个问题:

  • 在独立目录(部署我的应用程序的地方)中添加 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 时不再出现错误。 derby 驱动程序没有声明为模块,但它会在我的不同应用程序之间共享,所以没关系。