9 Replies Latest reply on Mar 21, 2011 1:09 PM by Max Rydahl Andersen

    Maven - WEB-INF/lib libraries

    German Escobar Newbie



      I've noticed that my Maven WAR module dependecies are being downloaded to the WEB-INF/lib libraries. This is a problem when I have to change dependencies in my POM. As a workaround, I just have to delete the WEB-INF/lib contents and they will be downloaded again. This is not the case, however, for the EAR libraries. The EAR lib folder is always empty and once the application is published, they are added to the generated package, which is what I would expect also for the WEB-INF/lib libraries.


      Am I missing some configuration?


      I'm using Eclipse 3.5, m2eclipse and JBoss Tools nightly build I downloaded a couple of days ago.



        • 1. Re: Maven - WEB-INF/lib libraries
          Snjezana Peco Master

          Those libraries are created by Maven/m2eclipse when calling "mvn package" or "mvn install".

          You can create a bug on https://issues.sonatype.org/browse/MNGECLIPSE

          • 2. Re: Maven - WEB-INF/lib libraries
            German Escobar Newbie

            The problem here is that Maven WAR plugin configuration points warSourceDirectory and webappDirectory to the same folder, which is ${basedir}/WebContent. This presents some problems as the webappDirectory is the folder in which the generated warSourceDirectory is going to be placed:


            1. This means that the libraries that are downloaded to the webappDirectory will be in the same warSourceDirectory (my initial problem).
            2. If I want to do some resource filtering, it will fail as the generated webappDirectory is the same warSourceDirectory.
            • 3. Re: Maven - WEB-INF/lib libraries
              Snjezana Peco Master

              You are right.

              I have created https://jira.jboss.org/jira/browse/JBIDE-5819

              As a workaround, you can remove the webappDirectory element from the pom.xml file.


              Thanks for solving this issue!

              • 4. Re: Maven - WEB-INF/lib libraries
                German Escobar Newbie

                I removed the webappDirectory element from the POM. However, the problem now is that I've lost hot deployment. When I change a file from my webapp, it says "Publishing to JBoss ... " as usual, but nothing gets really published. The EAR inside the JBoss deploy folder remains the same.


                What I'm doing now as a workaround is to run "mvn package" from the m2eclipse menu ... then it gets published.

                • 5. Re: Maven - WEB-INF/lib libraries
                  Snjezana Peco Master

                  You mean - hot deployment works if you add webappDirectory, but doesn't work if you remove it?

                  What JBoss AS are you using?

                  • 6. Re: Maven - WEB-INF/lib libraries
                    German Escobar Newbie

                    I'm using JBoss 4.2.3.GA. Sorry, I missed something on my last post. As I removed the webappDirectory element from the POM, all the WebContent structure is being "replicated" to the folder "target/myproject-1.0.0-SNAPSHOT". So, I had to change the WTP assembly to point to that folder instead of WebContent. Why? Well, multiple reasons:


                    • I use Maven's resource filtering on some descriptors (i.e. web.xml and jboss-web.xml).
                    • The WebContent/WEB-INF/lib/ doesn't have the libraries anymore (which is a good thing).
                    • The "target/myproject-1.0.0-SNAPSHOT" folder has the libraries and the resources after being filtered.


                    So far so good. Now, when I change a file from WebContent (i.e. home.xhtml), it is not copied to the "target/myproject-1.0.0-SNAPSHOT" folder. The "Publishing to JBoss .." messages appears  but as the file hasn't change in "target/..." folder, there is nothing to copy to the JBoss deploy directory. So, I see no changes in my app.


                    Once I run "mvn package", the "Publishing to JBoss ..." message appears again but this time it is published correctly to the JBoss deploy folder (now it has change in the "target/..." folder!).


                    Hope it makes more sense.


                    BTW, as the WebContent folder is "replicated", when I want to look for a resource, it appears duplicated; one for the WebContent folder and the other for the "target/myproject-1.0.0-SNAPSHOT" folder.

                    • 7. Re: Maven - WEB-INF/lib libraries
                      Leandro Iriarte Newbie

                      Hi German,


                      I think I am in the a similar situation than you one year later. My app runs OK if I keep the /lib/ folder with all the jars in the WAR project. I tried changing the assembly like you and now I have another error. I was wondering how did you handle the assembly for the EAR project. Did you change it as well?


                      Did you use maven from the console or always with the plugin?


                      Thanks, Leandro

                      • 8. Re: Maven - WEB-INF/lib libraries
                        Darryl Miles Novice

                        With regards to webappDirectory the default project layout with Maven for a WAR is to have src/main/webapp/WEB-INF/lib with src/main/webapp being your top level directory.  The WebContent/ is an ECLIPSEism.  Now it woule be good if the Maven plugin for Eclipse (m2e) could relocate (virtually) and link the src/main/webapp tree back at the top level of the project for easy access, like Java Source folders do.


                        So if you are messing with the webappDirectory setting (by removing it) in maven-war-plugin then be aware of the defaults.

                        • 9. Re: Maven - WEB-INF/lib libraries
                          Max Rydahl Andersen Master

                          Darryl, Project Explorer shows webresources at "root" level. Is that what you are asking for ?