Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Create Global Modules in JBoss AS7

In other Java application servers and previous versions of Jboss AS, there is the concept of common lib, where users can put shared libraries for use by all deployed apps. How to achieve the same effect in AS7 with Modules and their dependency? The easiest (not necessarily the best) way is to create a global module for a collection of shared jars.

1, Create a module directory structure: 

mkdir -p $JBOSS_HOME/modules/com/mycompany/myproject/main 

2, Copy common jar files to the above directory: 

cp my-util.jar my-service.jar $JBOSS_HOME/modules/com/mycompany/myproject/main

3, Create a module.xml file in the new module's main directory:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mycompany.myproject">
<dependencies>
<module name="javaee.api"/>
</dependencies>

<resources>
<resource-root path="my-util.jar"/>
<resource-root path="my-services.jar"/>
</resources>
</module>

4, Declare the module com.mycompany.myproject as a global module, by editing $JBOSS_HOME/standalone/configuration/standalone.xml. Add to the ee subsystem:

<subsystem xmlns="urn:jboss:domain:ee:1.1">
<global-modules>
<module name="com.mycompany.myproject" slot="main"/>
</global-modules>
</subsystem>

Editing server configuration files is not a good idea, but so far this is the only way of adding global modules.


This post first appeared on Java How To ..., please read the originial post: here

Share the post

How to Create Global Modules in JBoss AS7

×

Subscribe to Java How To ...

Get updates delivered right to your inbox!

Thank you for your subscription

×