1

I am trying to minimize my myapp.ear file to moving some libs to the server wildfly 10, but the easy only way I found was by including in standalone.xml deployments section, like the following example.

<deployments>
   <deployment name="mysql-connector-java-5.0.8-bin.jar" runtime-name="mysql-connector-java-5.0.8-bin.jar">
      <content sha1="7b9bfb6c4e4885660378a9c13330915c321f6cca"/>
   </deployment>
</deployments>

and I could use the libraries on maven as the example

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
</dependency>

Is there a easy way to add and load the libraries in ../lib or ../lib/ext?

Joe
  • 7,749
  • 19
  • 60
  • 110

2 Answers2

0

Create a module.xml file like his for your driver :

<module xmlns="urn:jboss:module:1.5" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>

Execute : .

/jboss-cli.sh -c --command="module add --module-xml=<path-to-file>/module.xml --resources=<path-to-file>/mysql-connector-java-5.0.8-bin.jar"
ehsavoie
  • 3,126
  • 1
  • 16
  • 14
0

To define a new module in wildfly 10 we can use jboss-cli.sh among others.

Create module dependency

../wildflly/bin$ ./jboss-cli
[standalone@localhost:9990 /] module add 
 --name=org.mysql 
 --resources=<path-res>/mysql-connector-java-5.1.45-bin.jar 
 --dependencies=javax.api,javax.transaction.api

I used as < path-res > ../standalone/lib

Create datasource driver

[standalone@localhost:9990 /]/subsystem=datasources/jdbc-driver=
mysql:add(driver-module-name=org.mysql,
 driver-name=mysql,
 driver-class-name=com.mysql.jdbc.Driver)

Create database source (as example with default mysql port)

[standalone@localhost:9990 /] /subsystem=datasources/data-source=
MySQLDS:add(jndi-name=java:jboss/datasources/MySQLDS, 
 driver-name=mysql, 
 connection-url=jdbc:mysql://localhost:3306/schema,
 user-name=root,
 password=pass)
Joe
  • 7,749
  • 19
  • 60
  • 110