I'm facing the followinf issue :
Failed to execute goal
org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml
(default-generate-application-xml) on project UserAdminEAR:
Artifact[war:com.syril.administration:UserAdmin] is not a dependency
of the project. -> [Help 1]
what is the solution for this kind of error?
my pom.xml is
<modelVersion>4.0.0</modelVersion>
<groupId>UserAdminEAR</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>UserAdmin</name>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<jarModule></jarModule>
<javaModule>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</javaModule>
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
You will have to add the war as a dependency to the project too, not only in the plugin configuration.
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>YOUR_VERSION_HERE</version>
<packaging>ear</packaging>
<dependencies>
<!-- some other dependencies here -->
...
<!-- Here is the dependency to the war that is referenced in the ear plugin -->
<dependency>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdmin</artifactId>
<version>YOUR_VERSION_HERE</version>
<type>war</type>
</dependency>
</dependencies>
...
</project>
Edit
The <webModule/> artifact is not in your <dependencies/> list. That is what I was suggesting.
Add the following:
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
OR
Change the <webModule/>:
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
That is of course if UserAdminService is the same as UserAdminSL which I think.
Related
I decided to migrate our legacy project from jdk7 to jdk11 and can't resolve problem with jaxb.
We have a multi-module maven project.
Here is a part of the parent pom
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.XXX.core.build</groupId>
<artifactId>parent</artifactId>
<version>2.1.2</version>
<packaging>pom</packaging>
<name>Core Build</name>
<prerequisites>
<maven>3.6</maven>
</prerequisites>
<modules>
<!-- <module>./targetdefs</module> -->
<module>../com.XXX.core</module>
....more modules
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk-version>11</jdk-version>
<!-- Plugins tycho version -->
<tycho.version>1.7.0</tycho.version>
<javax.activation.version>1.2.0</javax.activation.version>
<jaxb.api.version>2.3.0</jaxb.api.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- API -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<!--<scope>compile</scope>-->
</dependency>
<!--Runtime-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<source>${jdk-version}</source>
<target>${jdk-version}</target>
</configuration>
</plugin>
</build>
</project>
And here is the child pom
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.XXX.core.build</groupId>
<artifactId>parent</artifactId>
<version>2.1.2</version>
<relativePath>../com.XXX.core.build/pom.xml</relativePath>
</parent>
<artifactId>com.XXX.core</artifactId>
<packaging>eclipse-plugin</packaging>
<name>Core</name>
<dependencies>
<!-- API -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<!--<scope>compile</scope>-->
</dependency>
<!--Runtime-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}</directory>
<filtering>true</filtering>
<includes>
<include>**/version.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
But after trying to execute mvm clean install on child pom I'm getting
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.7.0:compile (default-compile) on project com.XXX.core: Compilation failure: Compilation failure:
[ERROR] PATH\core\util\stax\StaxIterator.java:[17]
[ERROR] import javax.xml.bind.JAXBContext;
[ERROR] ^^^^^^^^^^^^^^
[ERROR] The import javax.xml.bind cannot be resolved
Although Netbeans added jakarta.xml.bind-api and jaxb-impl as libraries and there are no any error in file StaxIterator.java
I followed this post How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
How could I resolve problem in such situation - I tried all the possibility from StackOverflow :(
The problem was SOLVED
There is no need to add dependencies to maven at all.
The root of the issue (in my case) was in file META-INF/MANIFEST.MF
I've just added javax.xml.bind to the "Import-Package:" section
...
Import-Package: javax.persistence,
javax.xml.bind,
org.apache.commons.beanutils,
org.osgi.framework;version="1.6.0",
org.osgi.service.event;version="1.3.0",
org.slf4j;version="1.7.30"
I have parent project - selenium and child project as project 1 , my intention is to have all the reusable classes in parent and test in child.When i try to run the test from child project i got the below error , could any one please help me."Failed to execute goal on project project1: Could not resolve dependencies for project com.aero:project1:pom:
1.0-SNAPSHOT: The following artifacts could not be resolved: com.automation:parentproject:jar:1.0-SNAPSHOT".I tried mvn clean and mvn install at parent project first and child project then executed mvn surefire:test but got the above exception.
Note: When i first build the parent project it doesnot generated the .jar file in the .M2 path
pom.xmL
-------
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.automation</groupId>
<artifactId>parentproject</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>project1</module>
</modules>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
</dependencies>
</project>
Child pom:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>selenium</artifactId>
<groupId>com.automation</groupId>
<version>1.0-SNAPSHOT</version>
</parent> <modelVersion>4.0.0</modelVersion>
<artifactId>project1</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.automation</groupId>
<artifactId>parentproject</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
1- you child pom referencing the wrong parent artifact.
2- direct dependency to "parentproject" should be removed, since its parent and not a dependency.
Parent:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.automation</groupId>
<artifactId>parentproject</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>project1</module>
</modules>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency><--!You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver-->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
</dependencies>
Child:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parentproject</artifactId>
<groupId>com.automation</groupId>
<version>1.0-SNAPSHOT</version>
</parent> <modelVersion>4.0.0</modelVersion>
<artifactId>project1</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
...
</dependency>
</dependencies>
hope this helps
The deployment to the Glassfish server fails because the Cargo plugin has an invalid property.
I have a multi module Maven project with this parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.skb</groupId>
<artifactId>ProjectMonkeybutler</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ProjectMonkeybutler</name>
<modules>
<module>ProjectMonkeybutler-ear</module>
<module>ProjectMonkeybutler-web</module>
<module>ProjectMonkeybutler-ejb</module>
</modules>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
I would like to execute an auto redeployment to my Glassfish server but this is not possible from the parent pom because it is not a war/ear file which will be produced. I integrated the Cargo plugin into the ear project but the deployment is not successful.
My pom.xml for the ear project.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" x mlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ProjectMonkeybutler</artifactId>
<groupId>com.skb</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.skb.monkeybutler.ear</groupId>
<artifactId>ProjectMonkeybutler-ear</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<name>ProjectMonkeybutler-ear</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.7</version>
<configuration>
<container>
<containerId>glassfish4x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
<cargo.remote.port>50447</cargo.remote.port>
<cargo.glassfish.domain.name>/domain1</cargo.glassfish.domain.name>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>ear</type>
<properties>
<context>/monkeybutler-dev</context>
</properties>
</deployable>
</deployables>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>3.2-b06</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.skb</groupId>
<artifactId>ProjectMonkeybutler-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.skb</groupId>
<artifactId>ProjectMonkeybutler-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
The error after
mvn cargo:deploy
ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.7:redeploy (default-cli) on project ProjectMonkeybutler-ear: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.7:redeploy failed: Invalid property [context] for deployable type [ear]: org.codehaus.cargo.container.deployable.EAR.setContext([Ljava.lang.String;) -> [Help 1]
The context property is only allowed for WARs.
See the column Deployable Type in the documentation: http://cargo.codehaus.org/Maven2+Plugin+Reference+Guide#Maven2PluginReferenceGuide-prop2
So I created this small maven plugin, that would connect to the database server and create all the tables I need for the project. Thing is, that the project consists of multiple modules and I want the plugin to be defined in the parent one. Yet it needs to be executed only once, not separately for each module. I thought that adding "<inherited>false</inherited>" to the plugin configuration would be enough, but apparently it's not.
Here's the pom of my parent project:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rpg</groupId>
<artifactId>rpg-build</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>rpg-build</name>
<modules>
<module>../rpg-web</module>
<module>../rpg-service</module>
<module>../rpg-commons</module>
<module>../rpg-maven-plugin</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>rpg.maven.plugin</groupId>
<artifactId>rpg-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<inherited>false</inherited>
</plugin>
</plugins>
<finalName>${artifactId}</finalName>
</build>
</project>
Answered in comments:
You should add #aggregator annotation to your plugin's mojo. – Andrew
Logvinov Apr 1 '13 at 12:40
I have a multimodule maven project with the following structure:
app (parent)
-- pom.xml
-- app-ear
-- pom.xml
-- app-ejb
-- src
-- pom.xml
-- app-web
-- src
-- pom.xml
app/pom.xml
This is my app/pom.xml (parent project) where I put all my application dependencies:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>app</name>
<url>http://maven.apache.org</url>
<modules>
<module>app-ejb</module>
<module>app-web</module>
<module>app-ear</module>
</modules>
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>4.2.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
app-ejb/pom.xml
This is my app-ejb/pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-ejb</artifactId>
<packaging>ejb</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is my app-web/pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-ejb</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>app-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
app-ear/pom.xml
And finally this is my app-ear/pom.xml where I have the detais about how generate my app.ear file:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-ejb</artifactId>
<type>ejb</type>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-web</artifactId>
<type>war</type>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<version>5</version>
<unpackTypes>war</unpackTypes>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
<modules>
<webModule>
<groupId>com.mycompany</groupId>
<artifactId>app-web</artifactId>
<bundleFileName>app-web.war</bundleFileName>
<contextRoot>/app</contextRoot>
</webModule>
<ejbModule>
<groupId>com.mycompany</groupId>
<artifactId>app-ejb</artifactId>
<bundleFileName>app-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-api</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-api</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</jarModule>
<jarModule>
<groupId>net.sourceforge.cssparser</groupId>
<artifactId>cssparser</artifactId>
</jarModule>
<jarModule>
<groupId>org.w3c.css</groupId>
<artifactId>sac</artifactId>
</jarModule>
<jarModule>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
My problem is that app.ear/app-web.war!META-INF/MANIFEST.MF and app.ear/app-ejb.jar!META-INF/MANIFEST.MF looks like this:
Manifest-Version: 1.0
Build-Jdk: 1.6.0_24
Class-Path: lib/javax.faces-2.0.9.jar lib/richfaces-core-api-4.2.0.Fin
al.jar lib/richfaces-core-impl-4.2.0.Final.jar lib/richfaces-componen
ts-api-4.2.0.Final.jar lib/richfaces-components-ui-4.2.0.Final.jar li
b/cssparser-0.9.5.jar lib/sac-1.3.jar lib/guava-10.0.1.jar lib/jsr305
-1.3.9.jar
Created-By: Apache Maven
Archiver-Version: Plexus Archiver
And I really have to remove the Class-Path entry from these MANIFEST.
Why? Because it seems that RichFaces is being loaded two times in classpath of my application. (One from app.ear/lib folder and another from app.ear/app-web.war!META-INF/MANIFEST.MF Class-Path entry). And when I try to deploy app.ear in my Application Server (Oracle Weblogic 10.3.5) I get some errors like that:
INFO: Unsanitized stacktrace from failed start...
java.lang.IllegalArgumentException: duplicate key: class javax.faces.validator.RequiredValidator
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:221)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:207)
at org.richfaces.javascript.ClientServiceConfigParser.parseConfig(ClientServiceConfigParser.java:53)
at org.richfaces.application.ValidatorModule.createClientScriptService(ValidatorModule.java:65)
at org.richfaces.application.ValidatorModule.configure(ValidatorModule.java:60)
at org.richfaces.application.ServicesFactoryImpl.init(ServicesFactoryImpl.java:27)
It's weird that if I run mvn package in my app-web project, the Class-path entry does not go to app-web.war/META-INF/MANIFEST.MF. It only occurs when I run mvn package in my app parent project.
So, how could I remove the Class-path entry of webModule and ejbModule MANIFEST file?
I found a similar problem in this thread but without a solution.
I appreciate any help.
Thanks,
Mauricio
You need to add the following entry in your app-ear/pom.xml inside the configuration tag
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Created-On>${build.timestamp}</Created-On>
<Ant-Version>${ant.version}</Ant-Version>
<Java-Version>${ant.java.version}</Java-Version>
</manifestEntries>
</archive>
In general the addDefaultImplementationEntries tag that is set to false prevents all default entries (like the one you want) to be written in the manifest. afterwards you can add whatever you want to include. I added some samples fo that you can see.