7 Replies Latest reply on Jun 29, 2012 9:51 AM by Vatsan Madabushi

    Add JARs outside of WAR to WARs classpath

    Stian Thorgersen Novice

      I would like to add all JARs from a folder outside of the WAR itself to the WARs classpath. Is this possible using "jboss-deployment-structure.xml"?

        • 1. Re: Add JARs outside of WAR to WARs classpath
          jaikiran pai Master

          What kind of jars are those? And where are they located?

          • 2. Re: Add JARs outside of WAR to WARs classpath
            Stian Thorgersen Novice

            I have a modular web app where the WAR itself only provides the core functionality, and is extensible by adding additional JARs with more CDI beans, JSF views, images, etc. The web app uses the ServiceLoader to detect the additional functionality.

             

            I don't have any exact requirements for where the JARs should be located, but I would like not to have to open the WAR to place them inside the WEB-INF/lib directory. I tried to add a module where I could add the JARs to the module, and then have web app have the the module as an optional dependency. However, I couldn't get it to detect he JSF views inside the JARs through this approach.

             

            The ideal solution would be to have a folder and have all JARs inside that folder put on the WARs class-path without having to modify the WAR. At first sight it seemed "<resource-root path="extensions" filter="*.jar"/>" could do it, but am I right in thinking that this will actually only place files from inside the WAR itself on the class-path?

             

            I guess it boils down to one of:

            - Is there a way to place JARs outside of the WAR on the class-path using "jboss-deployment-structure.xml"?

            - Is there a way to get JSF views (and other resources) loaded from a module?

            - Is there any other approach that could do this?

            • 4. Re: Add JARs outside of WAR to WARs classpath
              shadowcreeper Apprentice

              Is there any reason why you can't use an unpacked war and just copy files into the WEB-INF/lib directory?

              • 5. Re: Add JARs outside of WAR to WARs classpath
                Veit Guna Newbie

                Because I don't want to change the production artifact. So that it can be replaced on upgrades without affecting any customized code added by partners/customers.

                • 6. Re: Add JARs outside of WAR to WARs classpath
                  shadowcreeper Apprentice

                  Would sticking the war file inside of an exploded ear work? Then theoretically you should be able to stick the jars in the ear's lib directory.

                  • 7. Re: Add JARs outside of WAR to WARs classpath
                    Vatsan Madabushi Novice

                    I'm having the same issue.  I had to create a link in the myapp.war/WEB-INF/lib to point at myapp.ear/lib.  I really dont want to do that and I am using JBoss 7.1.1 Final.  The jboss-deploymetn structure was in myapp.ear/META-INF but diesnt seem to have any effect.  below is the deployment structure file.  Shouldnt the ear/lib path be automatically in the classpath fro all sub-deployments?

                     

                     

                    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
                        <!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->
                        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
                        <deployment>
                            <exclusions>
                                <module name="org.hibernate"/>
                            </exclusions>

                            <!-- These add additional classes to the module. In this case it is the same as including the jar in the EAR's lib directory -->
                            <resources>
                                  <resource-root path="wfm.jar" />
                            </resources>
                            <dependencies>
                                <module name="org.apache.log4j" export="true"/>

                           </dependencies>

                            </deployment>
                            <sub-deployment name="startup.war">

                                       <exclusions> <!-- Vatsan -->
                                           <module name="org.hibernate"/>
                                     </exclusions>
                                  <!-- This corresponds to the module for a web deployment -->
                                 <!-- it can use all the same tags as the <deployment> entry above -->
                                  <dependencies>
                                   <!-- Adds a dependency on a ejb jar. This could also be done with a Class-Path entry -->
                                   <!-- <module name="deployment.wfm.ear.wfm.jar" /> Vatsan -->
                                 </dependencies>
                             </sub-deployment>

                    </jboss-deployment-structure>