How to load jars residing over NFS in JBossAS7 classpath ? --reference
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 :
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
相关文章
- 算法之--快速排序
- Java -- IO -- 目录
- 7 -- Spring的基本用法 -- 8... 抽象Bean与子Bean;Bean继承与Java继承的区别;容器中的工厂Bean;获得Bean本身的id;强制初始化Bean
- Mysql执行大文件sql语句 -- 未测试
- Linux下高效切换目录 -- 目录栈 进行操作 dirs pushd popd
- 相控阵天线方向图--第3部分:旁瓣和锥削
- 统计学习方法笔记 -- 隐马尔可夫模型
- 并发编程--CountDownLatch、Semaphore、CyclicBarrier的区别及示例
- yocto编译时报错"fatal: the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead"如何处理?
- android常见错误--Unable to resolve target ‘android - 8’
- 浅析npm报错ENOTFOUND npm ERR! network request to https://npm.***.com/*** failed 及 .npmrc 文件的作用、npm --verbose命令
- docker Failed to get D-Bus connection 报错 docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
- 《C#零基础入门之百识百例》(五十一)面向对象概述 -- 一维多项式求值
- How To Do @Async in Spring--转
- 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener--转
- Five ways to maximize Java NIO and NIO.2--转
- 简约之美jodd--props属性使用
- How to Setup Replicated LevelDB Persistence in Apache ActiveMQ 5.9--转载
- How to Analyze Java Thread Dumps--reference
- migrate from weblogic to tomcat: directory mapping--reference
- 10 ways to be a faster code reviewer--reference
- 15+ tar command usages with examples – Unix/Linux--reference
- 转载--How to Install VMware Tools on CentOS 6.3
- ESP32系列--ESP32各个系列对比
- ESP32系列--第二篇 开发环境搭建-Ubuntu系统
- 曹工说Redis源码(3)-- redis server 启动过程完整解析(中)