Eclipse plugin test with maven Bundle is not found - java

I work in a new eclipse plugin project where I have created a plugin test project.
And I have no test but the compilation not working.
I have this error :
T E S T S
java.lang.RuntimeException: Bundle plugin-test is not found
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.getBundleClassLoader(OsgiSurefireBooter.java:162)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.createCombinedClassLoader(OsgiSurefireBooter.java:98)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91)
at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.runTests(AbstractUITestApplication.java:44)
at org.eclipse.e4.ui.internal.workbench.swt.E4Testable$1.run(E4Testable.java:73)
at java.lang.Thread.run(Thread.java:662)
My pom.xml of plugin-test 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>
<parent>
<groupId>com.example.plugin</groupId>
<artifactId>plug-parent</artifactId>
<version>4.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>eclipse-test-plugin</packaging>
<!-- <packaging>eclipse-plugin</packaging> -->
<groupId>com.example.plugin</groupId>
<artifactId>plugin-test</artifactId>
<repositories>
<repository>
<id>swtbot</id>
<url>http://download.eclipse.org/technology/swtbot/releases/2.2.1/</url>
<layout>p2</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.example.plugin</groupId>
<artifactId>plugin</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<!-- <requirement> -->
<!-- <type>eclipse-plugin</type> -->
<!-- <id>xyz-rcp-plugin</id> -->
<!-- <versionRange>0.0.0</versionRange> -->
<!-- </requirement> -->
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>org.eclipse.sdk.ide</product>
<application>org.eclipse.ui.ide.workbench</application>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>${temporary.directory}</directory>
<directory>/home/{login}/workspaceTestOtherPlugin2/tmp</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<version>1.0.0</version>
</project>
Have you an idea ?
Thanks per advance.

Related

Create SOAP web server with Java and Maven

I would like to create simple Java SOAP web service that should run on Tomcat 10. I'm using Eclipse and Maven for this purpose. I'm creating new Maven project and was stuck with Archetype selection. Which Archetype I should use?
Can I create project without selecting archetype? What basic section should exist in my pom.xml?
I would use maven-archetype-webapp.
Your pom will need some/all of the following to build a SOAP WS as a warfile to run in Tomcat.
<?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>foo.bar</groupId>
<artifactId>MyServiceWS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>MyServiceWS</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/jakarta.jws/jakarta.jws-api -->
<dependency>
<groupId>jakarta.jws</groupId>
<artifactId>jakarta.jws-api</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jakarta.xml.soap/jakarta.xml.soap-api -->
<dependency>
<groupId>jakarta.xml.soap</groupId>
<artifactId>jakarta.xml.soap-api</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
<build>
<finalName>MyServiceWS</finalName>
<directory>${basedir}/target</directory>
<!-- main -->
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<!-- test -->
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>${basedir}/src/main/webapp/WebContent</warSourceDirectory>
<warSourceExcludes>${basedir}/src/main/webapp/WEB-INF/web.xml</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

How to run a maven project on mac

I am trying to run a simple maven project from the mac terminal.
Here is my 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>HelloWorld</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!-- here we specify that we want to use the main method within the Controller class -->
<mainClass>com.helloworld.Countries</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
I did maven package.
and when I try to run:
java -jar target/HelloWorld-1.0.jar
… I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONValue
Is the java.lang.NoClassDefFoundError only on macOS? I did the same project on Windows and it works fine.
Is there anyway that we can make this independent of OS?
Solution was to use Maven-shade-plugin. Here is my final POM.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>Helloworld</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.test.HelloWorld</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Maven downloading a specific version, how can I force to download an other?

I'm struggling with this maven project.
When I try for example to clean or package the project I get an error like this
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
I already done a question about that but I realised that in my maven repository I don't have the 2.5 version I only have the 2.4.1 then maven go to the central repository to find that version and throws this error.
But I don't know why maven is looking for that 2.5 version, I'm not declaring it on the pom.xml so where I can change or force maven to look 2.4.1 version?
Also I need to say that this error happens in all my projects (there are all from the same domain)
This is the 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>
<groupId>dom.example.exampleframe</groupId>
<artifactId>project-parent-exampleframe</artifactId>
<version>0.0.11.c-SNAPSHOT</version>
</parent>
<groupId>dom.example.project</groupId>
<artifactId>project</artifactId>
<version>1.9.0-SNAPSHOT</version>
<name>project</name>
<packaging>pom</packaging>
<description>Esquelet d'una aplicació BaseFrame</description>
<url>http://pro-projectes.example.pro/projects/project</url>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<instrumentation>
<excludes>
<exclude>**/ejb/*.class</exclude>
<exclude>**/domain/*.class</exclude>
<exclude>**/services/*.class</exclude>
<exclude>**/*Exception.class</exclude>
<exclude>**/Constants*.class</exclude>
<exclude>**/IConstants*.class</exclude>
</excludes>
<ignores>
<ignore>.+logger\..+</ignore>
</ignores>
</instrumentation>
</configuration>
</plugin>
</plugins>
</build>
<!-- Perfils -->
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>domain</module>
<module>logic</module>
<module>resources</module>
<module>ejb</module>
<module>ui</module>
<module>citizen.ui</module>
<module>ear</module>
</modules>
</profile>
<profile>
<id>citizen</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
<module>domain</module>
<module>logic</module>
<module>resources</module>
<module>ejb</module>
<module>ui</module>
<module>citizen.ui</module>
<module>ear</module>
</modules>
</profile>
<profile>
<id>difuse</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
<module>domain</module>
<module>logic</module>
<module>resources</module>
<module>ejb</module>
<module>ear</module>
</modules>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<configuration>
<customBundle>${project.exampledir}/src/site/resources/project-info-report_ca.properties</customBundle>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<report>dependency-info</report>
<report>project-team</report>
<report>summary</report>
<report>scm</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- Només s'ha d'incloure-hi la definició -->
<excludePackageNames>dom.example.project.serveis.ejb;dom.example.project.serveis.impl;dom.example.project.ui</excludePackageNames>
<!-- No hem d'incloure-hi els arxius de test -->
<excludes>**/*Test.java</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.9</version>
<configuration>
<xmlPath>${exampledir}/src/site/changes.xml</xmlPath>
<issueLinkTemplatePerSystem>
<Redmine2><![CDATA[%URL%/issues/%ISSUE%]]></Redmine2>
</issueLinkTemplatePerSystem>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>cobertura</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<distributionManagement>
<site>
<id>mavendocs-example</id>
<name>mavendocs.example.dom</name>
<url>${example.url.mavendocs}</url>
</site>
</distributionManagement>
<modules>
<module>domain</module>
<module>recources</module>
<module>logic</module>
<module>ejb</module>
<module>ui</module>
<module>citizen.ui</module>
<module>ear</module>
<module>test</module>
</modules>
<dependencies>
<dependency>
<groupId>dom.example.tip</groupId>
<artifactId>tip.domain</artifactId>
<version>1.7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.sca</groupId>
<artifactId>sca.domain</artifactId>
<version>1.3.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.gea</groupId>
<artifactId>gea.domain</artifactId>
<version>2.5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>examplegd</groupId>
<artifactId>examplegd.domain</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<!-- Dependències del servei de registre. -->
<dependency>
<groupId>dom.example.res</groupId>
<artifactId>res.domain</artifactId>
<version>1.14.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Dependències del mòdul d'ASF. -->
<dependency>
<groupId>dom.example.exampleframe.modules.asf</groupId>
<artifactId>bf-modul-asf</artifactId>
<version>0.0.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.alerts</groupId>
<artifactId>alerts.domain</artifactId>
<version>0.0.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.gmc</groupId>
<artifactId>gmc.domain</artifactId>
<version>1.5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.gmc</groupId>
<artifactId>gmc.recursos</artifactId>
<version>1.5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom.example.exampleframe</groupId>
<artifactId>exampleframe-transicio</artifactId>
<version>[0.12.,1.0)</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
You look into child pom, look into a parent pom
<parent>
<groupId>dom.example.exampleframe</groupId>
<artifactId>project-parent-exampleframe</artifactId>
<version>0.0.11.c-SNAPSHOT</version>
</parent>
This should have been mentioned in one of your pom files either the child or in one of your parent or grandparent poms. You can use effective-pom goal to see the entire POM structure. This is the goal - org.apache.maven.plugins:maven-help-plugin:3.2.0:effective-pom

Merge Java module dependencies resources into WAR using Maven

I have a multiplatform project which has several language-specific profiles. The HTML-platform-specific module depends on an "assets-core" module and if "en" profile is enabled, an "assets-en" module resources should also be included into WAR.
Assembling WAR works just fine with an exception that if "assets-core" module contains file with the same file name as "assets-en", it is not overwritten by the file from "assets-en" module.
I tried to use maven-resource-plugin:
<build>
<resources>
<resource>
<directory>${basedir}/assets-en/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
with
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-prod-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/assets-ar/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
and <maven.resources.overwrite>true</maven.resources.overwrite> enabled as other threads suggests, but nothing worked.
maven-war-plugin overlays could also be the solution but I can't have resource module to be packaged with <type>war</type> because the same module is also included in Java project.
Here are the relevant parts of my pom.xmls:
asssets-core/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>assets-core</artifactId>
</project>
assets-en/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>assets-en</artifactId>
</project>
example-html/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>example-html</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-core</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>assets-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>en</id>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>assets-en</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
OK, so I finally have found a solution. You need to get rid of dependencies to modules and copy the resources using maven-resources-plugin:
example-html/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>example-html</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-core</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-assets-core</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/ExampleProject/</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/assets-core/src/main/resources/assets</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>en</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-assets-en</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/ExampleProject/</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/assets-en/src/main/resources/assets</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

EAR is packing two copies of WAR and JAR projects

My Maven EAR project packs my EAR with two copies of each of my libraries. One copy is always appended with the version (In my case 1.0-SNAPSHOT). Is there something screwed up in my POMs?
I keep getting these type of errors when i try and deploy to server:
Servlet [blah...] and Servlet [blah..] have the same url pattern: [/RegistrationService_V10].
My EAR project POM looks like this :
<?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>
<artifactId>AlmexOffice</artifactId>
<groupId>com.huwag</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ear</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<name>AlmexOFfice-ear JavaEE6 Assembly</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4</version>
<configuration>
<version>6</version>
</configuration>
</plugin>
</plugins>
<finalName>AlmexOffice-ear</finalName>
</build>
<dependencies>
<dependency>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
In the maven-ear-plugin, you have to specify your ejbmodule and webmodule
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<modules>
<ejbModule>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ejb</artifactId>
</ejbModule>
<webModule>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-web</artifactId>
<contextRoot>/custom-context-root</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
Could you give us the feedback if it works better?

Categories