David Balažic
David Balažic

Reputation: 1473

Maven leaves out a jar from WAR

We use maven 2.2.1 to build project. A master pom lists modules that are built (some WAR project and some "plain" JARs).

Recently we added a new dependency into one of the WAR projects:

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2.6</version>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
            <exclusion>
                <artifactId>commons-codec</artifactId>
                <groupId>commons-codec</groupId>
            </exclusion>
        </exclusions>
    </dependency>

When built locally from command line (mvn clean package) on a developers machine, it works fine. But when built on the automatic build system (by Hudson) the httpcore JAR (it is a dependency of httpclient) is not packaged into the final WAR. No error is reported, just the JAR is missing.

The maven settings.xml files are identical (except the repo path - the only noticeable non-default option is offline=true). What could be wrong?

Upvotes: 0

Views: 612

Answers (2)

David Balažic
David Balažic

Reputation: 1473

Problem found. (and solved)

In short: the httpclient.jar in the repo was without its .pom file. (so maven did not know it had dependencies)

Long:

It is an offline repository, so missing artifacts must be fixed manually. The problem is I first copied the files to the wrong folder and maven did not "see" them. Then "blindly" followed its advice:

Missing:
----------
1) org.apache.httpcomponents:httpclient:jar:4.2.6

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=org.apache.httpcomponents -DartifactId=
httpclient -Dversion=4.2.6 -Dpackaging=jar -Dfile=/path/to/file

That would just copy the jar file to the repo, without the pom.

So I just copied the complete folder for httpclient into the repo (and its parent and some other related files that maven then complained about).

It's a form of user error, I guess.

Upvotes: 1

Krzysztof Krasoń
Krzysztof Krasoń

Reputation: 27516

The only thing that comes to my mind is that your build machine has old version of one of your modules in m2 repo. Clear up whole $HOME/.m2/repository (or where you keep the repo) and try again.

Upvotes: 2

Related Questions