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的更多相关文章

  1. Linux 下 Error: Could not find or load main class Hello

    在linux下写了一个很easy的Hello world程序,编译执行居然报错:Error: Could not find or load main class Hello 最后发现是CLASSPAT ...

  2. Could not find or load main class Hello

    在 linux 下写了一个非常简单的 Hello World 程序,编译正常,运行报错:Error: Could not find or load main class Hello 这是由于 CLAS ...

  3. spark提交应用的方法(spark-submit)

    参考自:https://spark.apache.org/docs/latest/submitting-applications.html 常见的语法: ./bin/spark-submit \    ...

  4. spark-shell --conf

    spark-shell --conf -h Usage: ./bin/spark-shell [options] Options: --master MASTER_URL spark://host:p ...

  5. SparkSQL使用之Thrift JDBC server

    Thrift JDBC Server描述 Thrift JDBC Server使用的是HIVE0.12的HiveServer2实现.能够使用Spark或者hive0.12版本的beeline脚本与JD ...

  6. SparkSQL使用之Spark SQL CLI

    Spark SQL CLI描述 Spark SQL CLI的引入使得在SparkSQL中通过hive metastore就可以直接对hive进行查询更加方便:当前版本中还不能使用Spark SQL C ...

  7. Spark笔记——技术点汇总

    目录 概况 手工搭建集群 引言 安装Scala 配置文件 启动与测试 应用部署 部署架构 应用程序部署 核心原理 RDD概念 RDD核心组成 RDD依赖关系 DAG图 RDD故障恢复机制 Standa ...

  8. Spark:Spark 编程模型及快速入门

    http://blog.csdn.net/pipisorry/article/details/52366356 Spark编程模型 SparkContext类和SparkConf类 代码中初始化 我们 ...

  9. 用spark-submit启动程序

    来源:http://spark.apache.org/docs/latest/submitting-applications.html 提交程序常用的一些选项 ./bin/spark-submit \ ...

随机推荐

  1. Android JNI和NDK关系

    1.什么JNI Java Native Interface(JNI)标准是java平台的一部分,它允许Java代码和其他语言写的代码进行交互.JNI 是本地编程接口,它使得在 Java 虚拟机(VM) ...

  2. 搭建BCE本地开发环境

    1. 在官网下载VirtualBox & 虚拟机 http://bce.baidu.com/doc/BAE/GUIGettingStarted.html#.E4.B8.8B.E8.BD.BD. ...

  3. utf8_general utf8_general utf8_bin区别

    对与general来说 ß = s 是为true的 但是对于unicode来说 ß = ss 才是为true的, 其实他们的差别主要在德语和法语上,所以对于我们中国人来说,一般使用general,因为 ...

  4. C++关于构造函数的深拷贝与浅拷贝

    首先拷贝构造函数的声明方法: 类名::类名(const 类名&) 1.浅拷贝的实现程序: #include "stdafx.h" #include <iostream ...

  5. 一种计算e的方法

    原文地址:http://hankjin.blog.163.com/blog/static/3373193720108811316123/ 原理:平均e个(0,1)之间的随机数之和会大于1.原因:n个数 ...

  6. 关于如何在BCB中使用CodeGuard

    作者:深圳虫 来自:深圳虫网本文来自http://www.szbug.com/disparticle.aspID=4 一. 为什么写这篇东西自己在使用BCB5写一些程序时需要检查很多东西,例如内存泄漏 ...

  7. 利用js制作html table分页示例(js实现分页)

    有时候table的列数太长,不利于使用者查询,所以利用JS做了一个table的分页,以下为相关代码 一.JS代码 <script type="text/javascript" ...

  8. 基于物联网操作系统HelloX的智慧家庭体系架构

    基于物联网操作系统HelloX的智慧家庭体系架构 智慧家庭是物联网的一个分支应用,是一个被广泛认同的巨大IT市场空间.目前市场上已经有很多针对智慧家庭的产品或解决方案,但与移动互联网不同,智慧家庭至今 ...

  9. HDU 2553 N皇后问题(详细题解)

    这是一道深搜题目!问题的关键是在剪枝. 下面我们对问题进行分析: 1.一行只能放一个皇后,所以我们一旦确定此处可以放皇后,那么该行就只能放一个皇后,下面的就不要再搜了. 2.每一列只能放一个皇后,所以 ...

  10. 【转】BLE 学习记录

    原文网址:http://m.blog.csdn.net/blog/chiooo/43985401 BLE 学习记录 ANROID BLE 开发,基于 bluetoothlegatt 分析 mBluet ...