Search code examples
javajbossderbywildflywildfly-8

Adding a module in WildFly 8.2.0 Final release


I am new in JBoss and I try to add a jdbc driver for derby as a module in WidlFly 8.2.0.

What I did:

  • I added the org/apache/derby/main folder in the JBOSS_HOME/modules/system/layers/base directory
  • In this new folder, I added derbyclient.jar (from jdk 1.8.0_40, it contains the driver) and a new module.xml file.

The module.xml file is as follows:

 <?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>

Then, I updated the standalone.xml file as follows:

  • addition of this tag (in <extensions>): <extension module="org.apache.derby"/>

Declaration of my datasource and of the driver:

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

I am getting the following error when I start 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]`

Do you know what I did wrong?

Thanks in advance


Solution

  • I finally solved the issue by:

    • adding derbyclient.jar in the standalone directory (where my applications are deployed)
    • modifying the datasource declaration in the standalone.xml to make it reference the jar name :

    <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>...

    (I deleted the <drivers> tag, I don't use it anymore.)

    So, I don't have errors anymore when I start WildFly. The derby driver is not declared as a module, but it will be shared among my different applications, so that's ok.