In this article we will discuss how can we load jars residing over NFS in JBoss AS-7 classpath. In some development environment, when there are multiple jars and properties files are being used by multiple servers, it is good to put all of them in a central repository, so that if the files (jar/properties files/xmls) are modified, all the servers will pickup the latest version and there will be less overhead related to copying the latest versions to individual servers

NFS allows a user on a client computer to access files over a network in a manner similar to how local storage is accessed. I installed NFS using below link :


As JBoss AS-7 has introduced a module structure to load your custom jars. One can quickly create a custom module and put the required jars in them, with appropriate entries in module.xml . But in this case we would be needing an additional module directory, which would be residing over NFS server and we would map this to our local (client) server.

Step-1: Modify standalone.sh and add a separate module directory. To do this navigate to $JBOSS_HOME/bin and edit the file.

Search for keyword “module” and it should look like below :

if [ "x$JBOSS_MODULEPATH" = "x" ]; then

Edit the above section of your “standalone.sh” script and then add the “:” separated path of your module directories as following


#if [ "x$JBOSS_MODULEPATH" = "x" ]; then

Here /mnt/nfs/ is the directory, where our new module directory would be residing.

Step-2 : On the shared mount create below directory structure :

├── aaa
   └── bbb
       └── ccc
           └── main
               ├── module.xml
               ├── utility_JAR.jar



module.xml :


<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="aaa.bbb.ccc">
       <resource-root path="utility_JAR.jar"/>


Step-3 : Now lets create a simple application which would be using utility_JAR.jar (ClassLoaderTestWAR.war). The war file will have below structure :”

├── index.jsp
   ├── jboss-deployment-structure.xml
   ├── web.xml

Where :

index.jsp :

     <head><title>ClassLoader Demo</title></head>
     <body bgcolor="maroon" text="white">
                    <h1>Class Loader Demo..</h1>

       aaa.bbb.TestUtility utility=new aaa.bbb.TestUtility();
       String whichClassLoader=utility.sayWhichClassLoader();
       System.out.println("nnt -----> "+whichClassLoader);


jboss-deployment-structure.xml :


<?xml version="1.0" encoding="UTF-8"?>
       <module name="aaa.bbb.ccc" />


web.xml :




Step-4 : Now deploy the application and start the JBoss AS-7 server.

Step-5 : Access the application using : http://localhost:8080/ClassLoaderTestWAR

You will see something like below :

If the above output comes that means the jar was loaded from our new module directory, which resides over NFS.

Middlewaremagic Team 🙂

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.