使 jboss-client.jar 可用于 JBoss EAP 6 中的 WAR 应用程序的技巧是什么

What is the trick for making jboss-client.jar available to the WAR applications in JBoss EAP 6

在JBoss EAP 6.1中,有一个文件

JBOSS/bin/client/jboss-client.jar

它包含 Web 应用程序所需的所有客户端 类。但是,当我们安装 WAR 文件时,它看不到这些 类 可用。

为解决此问题,我们已将此 JAR 的副本包含在 war 文件 WEB-INF/lib 文件夹中。这些副本是一种浪费,但更重要的是,这意味着我们必须为每个要安装的应用程序服务器准备一个不同的 WAR 文件。

是否有技巧允许 WAR 文件中的应用程序加载和使用此库中的 类,而无需将其复制到 WEB-INF/lib应用程序的文件夹?或者,是否有我们可以复制此 jar 的地方,以便所有 WAR 应用程序都可以使用它?

检查 Jboss 模块以使库作为 Jboss 的外部模块可用。 https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/chap-Class_Loading_and_Modules.html

解决方案是在 WEB-INF 文件夹中放置一个名为 jboss-deployment-structure.xml 的文件。该文件的内容是:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <!-- Excluding conflicting JBoss-6 Implicit Modules so that jars bundled within war file is used. -->
    <exclusions>
        <module name="org.apache.log4j" />
        <module name="org.apache.commons.logging" />
    </exclusions>
    <!-- Defining additional dependencies for JMS usage in model API -->
    <dependencies>
        <module name="org.jboss.remote-naming" />
        <module name="org.hornetq" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

这使我们能够使用来自 JBoss 的 JMS 类,而无需正在安装的应用程序中包含客户端库的副本。似乎前段时间,一个程序员将​​应用程序移植到JBoss,运行变成了一个问题,通过将客户端库放入"solved"(被黑),但这还很远更好的解决方案。