首页 > 其他 > 详细

How to load jars residing over NFS in JBossAS7 classpath ? --reference

时间:2014-08-07 12:50:10      阅读:304      评论:0      收藏:0      [点我收藏+]

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 :

Remote_Disk_Access_with_NFS#Installing_NFS

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
    JBOSS_MODULEPATH="$JBOSS_HOME/modules"
fi
..

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

..
JBOSS_MODULEPATH=/mnt/nfs:$JBOSS_HOME/modules

#if [ "x$JBOSS_MODULEPATH" = "x" ]; then
  #  JBOSS_MODULEPATH="$JBOSS_HOME/modules"
#fi
..

 

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

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

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

..

 

where

module.xml :

..

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

..

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

..
ClassLoaderTestWAR.war/
├── index.jsp
├── WEB-INF
   ├── jboss-deployment-structure.xml
   ├── web.xml
..

 

Where :

index.jsp :

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

<%
       aaa.bbb.TestUtility utility=new aaa.bbb.TestUtility();
       String whichClassLoader=utility.sayWhichClassLoader();
       System.out.println("\n\n\t -----> "+whichClassLoader);
       out.println("<h1>"+whichClassLoader+"</h1>");
%>

      </body>
</html>
..

 

jboss-deployment-structure.xml :

..

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

..

web.xml :

..

<web-app>
   <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
</web-app>

..

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 :

bubuko.com,布布扣

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

原文地址:http://middlewaremagic.com/jboss/?p=2561

How to load jars residing over NFS in JBossAS7 classpath ? --reference,布布扣,bubuko.com

How to load jars residing over NFS in JBossAS7 classpath ? --reference

原文:http://www.cnblogs.com/davidwang456/p/3896694.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!