Maven POM and Idea web artifacts differ

Having some issues with a Maven project, that is also a Maven project inside IDEA. When I build with the POM on the command line I get a different set of jars in the war/target folder than when I generate a web artifact for running the app via tomcat inside IDEA.

They're both using the same maven and same maven repo. The artifacts appear to be created via the maven pom, they appear automatically if I create a new exploded folder. But the same dependencies don't appear in the maven sidebar view of dependencies? So it's not clear where they've come from. This is a single module project.

Heres the kins of diff I'm seeing. On the left I have a the list of jars created via command line mvn install, on the right is the contents of WEB-INF/libs after clearing out and rebuilding web artefacts. The files in green are the extra ones IDEA adds that I don't want to see. Why would these differ?

IDEAMavenArtefactsDiff.png

5 comments
Comment actions Permalink

Hi Richard,

I had similar issues in the past and ended up with this work-around in order to have consistent builds:
I'm always using maven for building (e.g Maven Projects/install, I'm never using Build/Rebuild or Build/Make). Then, my artifacts are configured to be the wars generated by maven (e.g in target folder).

There are several things that may be causing your problem:
- go to Project Settings/Modules/<Your Module>/Dependencies and see if some of those you mentioned are there.
- go to Project Settings/Modules/<Your Module>/Web facet/Web Resource Directories and see which directories are included there, then check these folders if they contain these unnecessary jars.
- do you have artifacts other than Web (e.g javaEEApplication or similar?)

I'll try to elaborate later
Ivaylo

0
Comment actions Permalink

The additional jars don't appear in the module dependencies, these look to match the Maven sidebar display of dependencies and I'm sure no extra ones have been manually added or removed - this is all populated from the POM. The latter two lists seem to match the command line maven output.

The extra jars appear at the web artefact level. They're not sources I'v added, if I create a fresh new web artefact they get added to WEB-INF/lib automatically. They seem to reflect the contents of the other dependencies but none of these jars are ones I recognize or want. The additional stax jars it produces where the most worrisome as it appears to mix both stax2 and stax1.2 in the same webapp when only stax2 is a dependency.

I'm wondering if the web exploded folder builder uses the same maven configuration or not? we do have a local artifactory repository to hold compnay published modules that should deal with all dependencies before sourcing them from the public repos. I wonder if something is different with the resolution?

0
Comment actions Permalink

Think I've noticed the pattern to these unwanted addtional jars. Seems they're all subject of group exclusions in some fashion. Maven appears to handle these correctly, but the IDEA web artefact builder is getting it wrong and including optional forms of the exclusions?

These exclusions in our POM seem a bit too much of a coincidence to ignore, they also all use an artifactId wildcard:

          <dependency>                <groupId>com.lowagie</groupId>                <artifactId>itext</artifactId>                <version>2.1.7</version>                <exclusions>                     <exclusion>                          <groupId>bouncycastle</groupId>                          <artifactId>*</artifactId>                     </exclusion>                     <exclusion>                          <groupId>org.bouncycastle</groupId>                          <artifactId>*</artifactId>                     </exclusion>                </exclusions>           </dependency>                      <dependency>                <groupId>org.apache.activemq</groupId>                <artifactId>activemq-core</artifactId>                <version>5.7.0</version>                <scope>runtime</scope>                <exclusions>                 <!-- exclude jars that cause classloader conflicts when JBoss starts up -->                     <exclusion>                          <groupId>org.apache.geronimo.specs</groupId>                          <artifactId>*</artifactId>                     </exclusion>                     <exclusion>                          <groupId>org.apache.activemq</groupId>                          <artifactId>*</artifactId>                     </exclusion>                     <exclusion>                          <groupId>org.osgi</groupId>                          <artifactId>org.osgi.core</artifactId>                     </exclusion>                </exclusions>           </dependency>                      <dependency>                <groupId>org.apache.solr</groupId>                <artifactId>solr-core</artifactId>                <version>1.3.0</version>                <exclusions>                     <exclusion>                          <!-- stax-api.jar already exists in the JBoss client libraries directory                               and having it again in the EAR/WAR causes classloader problems -->                          <groupId>stax</groupId>                          <artifactId>*</artifactId>                     </exclusion>                     <exclusion> <!-- Excluded because correct groupId is org.codehaus.woodstox (and this                               is brought in elsewhere anyway) -->                          <groupId>woodstox</groupId>                          <artifactId>wstx-asl</artifactId>                     </exclusion>                </exclusions>           </dependency>                                                    

0
Comment actions Permalink

IDEA doesn't handle correctly wildcards in "<exclusion>" elements - as described here:
http://youtrack.jetbrains.com/issue/IDEA-90858

However, the artifacts I'm excluding in my project do appear in the Project Settings/Modules/<module_name>/Dependencies (that's why I asked you about this). They were auto-added there when I imported my project.
So I'm able to remove those from the project dependencies and consequently they are not packaged into the WAR (strange why they do not appear there in your case?).

I'm using IDEA 14 EAP btw.

0
Comment actions Permalink

I suspect that while I could remove them from the artifact view, this removal would not persist past the next change to or re-import of the POM? As its an autogenerated list.

Guess I'll have to vote on the ticket a ticket thats been open since 2012? ouch.

Thanks.

0

Please sign in to leave a comment.