Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

jboss7.x - How can I use the external jars on JBoss 7?

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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).

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.

Applications MANIFEST.MF:


Dependencies: commons.test

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...