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
How to load jars residing over NFS in JBossAS7 classpath ? --reference的更多相关文章
- Linux 下 Error: Could not find or load main class Hello
在linux下写了一个很easy的Hello world程序,编译执行居然报错:Error: Could not find or load main class Hello 最后发现是CLASSPAT ...
- Could not find or load main class Hello
在 linux 下写了一个非常简单的 Hello World 程序,编译正常,运行报错:Error: Could not find or load main class Hello 这是由于 CLAS ...
- spark提交应用的方法(spark-submit)
参考自:https://spark.apache.org/docs/latest/submitting-applications.html 常见的语法: ./bin/spark-submit \ ...
- spark-shell --conf
spark-shell --conf -h Usage: ./bin/spark-shell [options] Options: --master MASTER_URL spark://host:p ...
- SparkSQL使用之Thrift JDBC server
Thrift JDBC Server描述 Thrift JDBC Server使用的是HIVE0.12的HiveServer2实现.能够使用Spark或者hive0.12版本的beeline脚本与JD ...
- SparkSQL使用之Spark SQL CLI
Spark SQL CLI描述 Spark SQL CLI的引入使得在SparkSQL中通过hive metastore就可以直接对hive进行查询更加方便:当前版本中还不能使用Spark SQL C ...
- Spark笔记——技术点汇总
目录 概况 手工搭建集群 引言 安装Scala 配置文件 启动与测试 应用部署 部署架构 应用程序部署 核心原理 RDD概念 RDD核心组成 RDD依赖关系 DAG图 RDD故障恢复机制 Standa ...
- Spark:Spark 编程模型及快速入门
http://blog.csdn.net/pipisorry/article/details/52366356 Spark编程模型 SparkContext类和SparkConf类 代码中初始化 我们 ...
- 用spark-submit启动程序
来源:http://spark.apache.org/docs/latest/submitting-applications.html 提交程序常用的一些选项 ./bin/spark-submit \ ...
随机推荐
- Window.onload事件
window.onload是一个事件,当文档加载完成之后就会触发该事件,可以为此事件注册事件处理函数,并将要执行的脚本代码放在事件处理函数中,于是就可以避免获取不到对象的情况
- Wdcp缺少mod_rewite模块
1.下载apache源码包,解压并查找到mod_rewrite.c文件 tar -zxvf httpd-2.2.27.tar.gz cd httpd-2.2.27 [root@localhost ht ...
- 通过命令修改wampserver的mysql密码
WAMP安装好后,mysql教程密码是为空的,那么要如何修改呢?其实很简单,通过几条指令就行了,下面我就一步步来操作. 首先,通过WAMP打开mysql控制台. 提示输入密码,因为现在是空,所以直接按 ...
- PHPCMS二层栏目调用
{pc:content action="category" catid="0" num="25" siteid="$siteid& ...
- android 学习第一步
今天是2015年7月24号,今年下半年的主要学习方向是android,学习的目标是做出3个或以上的有实用价值的app.
- UIview lianxi
// 创建一个和屏幕大小相同的window,记住[UIScreen mainScreen].bounds 是获取当前屏幕大小 self.window = [[[UIWindow alloc] init ...
- 转:PHP开发者应了解的24个库
原文来自于:http://blog.jobbole.com/54201/ 作为一个PHP开发者,现在是一个令人激动的时刻.每天有许许多多有用的库分发出来,在Github上很容易发现和使用这些库.下面是 ...
- 【Java】Java Servlet 技术简介
Java 开发人员兼培训师 Roy Miller 将我们现有的 servlet 介绍资料修改成了这篇易于学习的实用教程.Roy 将介绍并解释 servlet 是什么,它们是如何工作的,如何使用它们来创 ...
- A Knight's Journey
poj2488:http://poj.org/problem?id=2488 题意:给你一张地图,然后有一个骑士,骑士可以从地图的任意一个方格开始,作为起点,问你该骑士能否走遍整张题图.题解:首先想到 ...
- cf C. Inna and Candy Boxes
题意:给你一个长度为n的只含有1和0的字符串,w个询问,每次询问输入l,r:在[l,r]中在l+k-1.l+2*k-1.......r的位置都必须为1,如果不为1的,变成1,记为一次操作,其它的地方的 ...