I have a web-app configured with a pom.xml.
This web-app relies on another maven module that produce a jar file. When i check the produced jar file size it is 8Ko. When i check this same jar file in my /lib web application, it is 5Ko.
A bunch of classes are simply ignored when the jar file reaches my /lib directory,
causing ClassNotFoundException when runing the web application.
Why is my jar trimmed ?
Web-app pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>record</artifactId>
<groupId>com.company.record</groupId>
<version>1.0.0</version>
</parent>
<groupId>com.company.record</groupId>
<artifactId>record-webapp</artifactId>
<packaging>war</packaging>
<name>record-webapp</name>
<version>1.0.0</version>
<dependencies>
<!-- JSF 2.0 -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3-b02</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.3-b02</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Internal dependencies -->
<dependency>
<groupId>com.company.record</groupId>
<artifactId>record-dao</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>record</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<serverName>web</serverName>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
</repositories>
record-dao pom.xml
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>record</artifactId>
<groupId>com.company.record</groupId>
<version>1.0.0</version>
</parent>
<groupId>com.company.record</groupId>
<artifactId>record-dao</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>record-dao</name>
<dependencies>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.4.Final</version>
<exclusions>
<exclusion>
<artifactId>cglib</artifactId>
<groupId>cglib</groupId>
</exclusion>
<exclusion>
<artifactId>antlr</artifactId>
<groupId>antlr</groupId>
</exclusion>
<exclusion>
<artifactId>jta</artifactId>
<groupId>javax.transaction</groupId>
</exclusion>
<exclusion>
<artifactId>commons-collections</artifactId>
<groupId>commons-collections</groupId>
</exclusion>
<exclusion>
<artifactId>hibernate-commons-annotations</artifactId>
<groupId>org.hibernate</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Postgresql -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-606.jdbc4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Internal dependencies -->
<dependency>
<groupId>com.company.record</groupId>
<artifactId>record-commun</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
I finally find a solution. In the web-app/web-inf/lib directory, there was a jar file who was sharing the same name with the dependent jar file.
For a reason I don’t understand, maven-war-plugin used to take this old jar file rather than the freshly one I installed in my local repository.