如何在JBoss 7上使用外部jar? [英] How can I use the external jars on JBoss 7?

查看:170
本文介绍了如何在JBoss 7上使用外部jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我可以加载EAR/lib下的jars. 但是我想把罐子放在一个通用的路径上,以供其他应用程序使用. 我发现jboss-deployment-structure.xml文件的标签可以做到这一点. 但这是行不通的.我收到了ClassNotFound异常. 我不知道为什么?

Now I can load jars which is under the EAR/lib. But I want to put the jars to a common path, for other application to use. I found that jboss-deployment-structure.xml file's tag can do this. But it doesn't work. I got the ClassNotFound exception. I don't know why?

<deployment>
   <resources>
        <resource-root path="/common/test.jar" />
   </resources>
 </deployment>

推荐答案

通过将全局库作为模块使用,可以实现在不同应用程序中使用全局库的一种方法. 因此,通过您作为服务器提供程序提供的库来扩展模块.

One way of using global libraries in different applications can be reached by making them available as modules. Therefor, extend the modules by the library you are providing as a server provider.

示例: 要使test.jar对所有应用程序都可用,请创建一个包含模块名称和main子目录的文件夹(例如modules/commons/test/main).

Example: To make your test.jar available to all applications, create a folder with the modules name and a main subdirectory (e.g. modules/commons/test/main).

将您的库和一个名为module.xml的模块描述文件放置在此处. 示例内容:

Place your library there and a module description file with the name module.xml. Example content:

<module xmlns="urn:jboss:module:1.0" name="commons.test">
    <resources>
        <resource-root path="test.jar"/>
    </resources>
</module>

现在该库可用于所有应用程序. 要访问该模块,您的应用程序必须在清单中定义依赖项.

Now the library is available to all applications. To get access to the module, your application has to define the dependency in the manifest.

应用程序 MANIFEST.MF :

Dependencies: commons.test


这也可以在构建期间由maven完成. 检查 https://docs.jboss.org/author/display/AS7/Class + Loading + in + AS7 了解详情


This can be also done by maven during build time. Check https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 for details

请注意,您正在修改服务器本身.使用模块的所有应用程序都取决于它.依赖模块commons.test的应用程序不会部署在没有提供此模块的服务器上.

Please note that you're modifying the server itself. All applications using your module are depending on it. A application with a dependency to the module commons.test wont be deployed on a server which does not have this module provided.

这篇关于如何在JBoss 7上使用外部jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆