Search code examples
javamavenwarwildfly-8

Refer to deployed jar as maven dependency


folks, please advise. I have a maven project with many maven modules. Those modules are java web applications and one jar, on which those web apps depend and which contains core functionality (let's call it core.jar). I deploy them to stable release of Wildfly app server with no problem and everything works fine. However, I noticed that all of my war files contain the same core.jar in the WEB-INF/lib folder. Could you tell me if it is possible to deploy this core.jar only once and make all war files see it? The only thing I could think of now is to install this core.jar as a jboss module (like this) and refer to it from manifest file in every web app. What do you think?

Regards, Oleg


Solution

  • Probably the best solution would be to create JBoss modules. Here is an example of using OJDBC. Also, you need to configure a shared lib. You can use a JBoss specific deployment descriptor, named jboss-app.xml which is to be placed in the META-INF folder of your EAR. Here's a sample of it:

    <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 5.0//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd" >
    <jboss-app>
        <library-directory>APP-INF/lib</library-directory>
    </jboss-app>
    

    It might be valuable for you to check the class loading specs.