ClassNotFoundException in multi module maven project - java

I am trying to build multi module project using maven. following are the modules
1) base
2) common
3) client
4) service
pom.xml of base project is
<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.se</groupId>
<artifactId>base</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>base Maven Webapp</name>
<url>http://maven.apache.org</url>
<modules>
<module>common</module>
<module>client</module>
<module>service</module>
</modules>
<dependencies>
...
</dependencies>
<build>
<finalName>base</finalName>
<plugins>
....
</plugins>
</build>
</project>
pom.xml of common module
<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.vdcommon</groupId>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<name>VDCommon Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.se</groupId>
<artifactId>base</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<dependencies>
...
</dependencies>
<build>
<finalName>common</finalName>
<plugins>
...
</plugins>
</build>
</project>
pom.xml of client module
<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.se</groupId>
<artifactId>base</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<groupId>com.vdclient</groupId>
<artifactId>client</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<name>VDClient Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
....
</properties>
<dependencies>
<dependency>
<groupId>com.vdcommon</groupId>
<artifactId>common</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
....
</dependencies>
<build>
<finalName>client</finalName>
<plugins>
<plugin>
....
</plugin>
</plugins>
</build>
</project>
pom.xml of service module
<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.se</groupId>
<artifactId>base</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<groupId>com.vdservice</groupId>
<artifactId>service</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>vdservcie Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
....
</properties>
<dependencies>
....
<dependency>
<groupId>com.vdclient</groupId>
<artifactId>client</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
....
</dependencies>
<build>
<finalName>service</finalName>
<plugins>
....
</plugins>
</build>
</project>
'service' module is a war file to deploy and test. I am able to do maven install for all the modules successfully and I am able to see the jar files of client and common modules in dependency tree.
[INFO] +- com.vdclient:client:jar:0.1-SNAPSHOT:compile
[INFO] | \- com.vdcommon:common:jar:0.1-SNAPSHOT:compile
But when I try to deploy the service war file into tomcat server I am getting ClassNotFoundException for a class which is present in client module
Caused by: java.lang.TypeNotPresentException: Type logical.lookuplogicalds_ws.PartyLookupDS not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:283)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:283)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1205)
at java.beans.Introspector.getBeanInfo(Introspector.java:426)
at java.beans.Introspector.getBeanInfo(Introspector.java:173)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:277)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:186)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:321)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:328)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1305)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 33 more
Caused by: java.lang.ClassNotFoundException: logical.lookuplogicalds_ws.PartyLookupDS
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1352)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
... 56 more
can anyone please help me on fixing this issue?

You need to make sure that you're bundling all of the libraries into the war file. If it builds correctly but the war is missing the related libraries it will fail when you deploy it.
For example, at package time where are you putting the libraries you depend on? And how are you building your war to include those libraries?
Most likely you can solve your problem using the Maven War Plugin. It will help you package all of the libraries you need into your war.
https://maven.apache.org/plugins/maven-war-plugin/
That will setup your maven project to create your war with what you need.

Related

Why Maven fails to manage version of war type dependency?

We have a multi module project where we define several dependencies in parent pom under dependencyManagement tag to manage dependencies version.
It works fine for several modules but one.
Parent 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.org.product</groupId>
<artifactId>product-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<parade-web.version>2.0.0</parade-web.version>
<!-- other properties -->
</properties>
<modules>
<module>../ProductWeb</module>
<!-- other modules -->
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.org.parade</groupId>
<artifactId>ParadeWeb</artifactId>
<version>${parade-web.version}</version>
</dependency>
<!-- other dependencies -->
</dependencies>
</dependencyManagement>
</project>
ProductWeb 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>my.org.product</groupId>
<artifactId>product-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../productparent</relativePath>
</parent>
<artifactId>ProductWeb</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency> <!-- 'dependencies.dependency.version' for my.org.parade:ParadeWeb:jar is missing. -->
<groupId>my.org.parade</groupId>
<artifactId>ParadeWeb</artifactId>
<type>war</type>
</dependency>
<!-- other dependencies -->
</dependencies>
</project>
If I add <version>${parade-web.version}</version> in my ProductWeb pom, NetBeans warns me that
Overrides version defined in DependencyManagement. The managed version is 2.12.2-RELEASE.
The only difference between this dependency and the other is the war type, but I don't get why dependency management fails to sets its version.
UPDATE
I managed to omit version tag but I needed to add <type>war</type> on both parent and child.
I don't understand. Does parent try to resolve dependency version looking for a war but then doesn't pass it through its children?
Add <type>war</type> to the dependencyManagement. This should do the trick.

Maven child module not found when building

I am trying to learn how maven multi-project builds work. I have a very simple setup right now, a top level POM that defines 1 subproject, the web application, and a web project that has a pretty basic pom file. From the parent level directory, when i try to run 'mvn clean install' i get the following error:
Child module /home/jeb/Desktop/payroll/payroll-web> of /home/jeb/Desktop/payroll/pom.xml does not exist
Here is the parent 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>payroll</groupId>
<artifactId>payroll-top</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>payroll-web></module>
</modules>
</project>
And here is the subproject (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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>payroll-web</name>
<parent>
<groupId>payroll</groupId>
<artifactId>payroll-top</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>payroll</groupId>
<artifactId>payroll-web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
</dependencies>
<build>
<finalName>payrollwebapp</finalName>
</build>
</project>
I'm not sure what I am missing to get the project to build, any help is appreciated.
You have a trailing ">" at the end of the module name.
<module>payroll-web></module>
`<parent>
<groupId>payroll</groupId>
<artifactId>payroll-top</artifactId>
<version>*0.0.1-SNAPSHOT*</version>
<relativePath>../pom.xml</relativePath>
</parent>`
Correct the parent version to 1.0

Use of environment variable in POM.xml doesn't work

I am trying to pull out the version number of the POM and all the dependencies to a environment variable. For example:
<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>
<artifactId>example-assembly</artifactId>
<name>example-assembly</name>
<properties>
<current.version>${env.CURRENTVERSION}</current.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example.demo</groupId>
<artifactId>exceptions</artifactId>
<version>${current.version}</version>
</dependency>
<dependencies>
<packaging>war</packaging>
<version>${current.version}</version>
</project>
With the above setup, when I run mvn clean command I am getting following error:
dependencies.dependency.version for example-assembly:war must be a valid version but is '${env.CURRENTVERSION}'
Any idea about what could be the issue?
Note: I am running maven in windows OS
There is a better alternative for updating Versions in pom.xml than using environment variables inside pom.xml: Versions Maven Plugin. This allows you to change pom.xml using maven command line.
Sample scenario
Project Structure:
+ P (Parent - Version 1.0.0-SNAPSHOT)
-- C1 (Child Project 1 - Version 1.0.0-SNAPSHOT)
-- C2 (Child Project 2 - Version 1.0.0-SNAPSHOT also depends on C1)
Task
You want to change version in all pom.xml files to 1.0.1-SNAPSHOT
Parent pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Parent</name>
<packaging>pom</packaging>
<modules>
<module>c1</module>
<module>c2</module>
</modules>
</project>
Child Project 1 pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>c1</artifactId>
<name>Child Project 1</name>
<packaging>jar</packaging>
<parent>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
</project>
Child Project 2 pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>c2</artifactId>
<name>Child Project 2</name>
<packaging>jar</packaging>
<parent>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>sample</groupId>
<artifactId>c1</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Command
Command to set new version in all pom.xml files
mvn -B -DnewVersion=1.0.1-SNAPSHOT versions:set
In case new version is represented by environment variable CURRENTVERSION
mvn -B -DnewVersion=$CURRENTVERSION versions:set
Here -B means --batch-mode (so new version won't be prompted on console)
Resultant files would be
Parent pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.1-SNAPSHOT</version>
<name>Parent</name>
<packaging>pom</packaging>
<modules>
<module>c1</module>
<module>c2</module>
</modules>
</project>
Child Project 1 pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>c1</artifactId>
<name>Child Project 1</name>
<packaging>jar</packaging>
<parent>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
</project>
Child Project 2 pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>c2</artifactId>
<name>Child Project 2</name>
<packaging>jar</packaging>
<parent>
<groupId>sample</groupId>
<artifactId>p</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>sample</groupId>
<artifactId>c1</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
The variable you define has the scope in the same pom.xml only and cannot be used in any other pom.
If you want to define the variable globally define it in settings.xml of maven.
Define the variable env.CURRENTVERSION somewhere in the the same pom, root pom or settings.xml
or else provide the exact version value in its place.
<properties>
<current.version>'your correct version'</current.version>
</properties>
e.g.
<properties>
<current.version>1.0.0</current.version>
</properties>

Teamcity, build maven project with parent dependency

I've 1 project with one subproject in my teamcity server. The subproject has the pom.xml file that references parent project.
This is the pom.xml of the project:
<?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>it.company.project</groupId>
<artifactId>MyProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MyProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>Foo</module>
</modules>
</project>
This is the pom.xml of the subproject:
<?xml version="1.0"?>
<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>it.company.project</groupId>
<artifactId>MyProject</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>Foo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>subproject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
</resources>
</build>
</project>
When I run the maven build from my IDE (IntelliJ IDEA) on my subproject, all works fine. Also when I run maven build on the parent project all works fine.
When I run build agent (configured to run pom.xml) from TeamCity server on my subproject it doesn't work, and I've the following errors:
[Step 1/1] Error reading Maven project: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact it.company.project:MyProject:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 5, column 13
.
[14:08:12][Step 1/1] TeamCity is unable to read Maven project. Some features may be unavailable
When I run build agent (configured to run pom.xml) from TeamCity server on my parent project it doesn't work, and I've the following errors:
An error occurred during collecting Maven project information: File not found in any VCS root: subproject/pom.xml.
My subproject build configurations:
What's wrong?
Thanks

Invalid packaging for parent pom.xml, must be "pom" but is "ear"

Could anybody suggest me an solution with the following exception. I am going to create a multi-module project.
Parent Project name is LOGICBACKEND
child project name is DBAccess
I need to have ear file of LOGICBACKEND which should contain DBAccess prjoects jar file.
I am getting following exception when i run mav clean install -P Developer.
[ERROR]The project com.project1.Database:DBAccess:1.0-SNAPSHOT (C:\Project1\DBAccess\pom.xml) has 1 error
[ERROR]Invalid packaging for parent POM com.project1.logic:LOGIC:1.0-SNAPSHOT (C:\Project1\pom.xml), must be "pom" but is "ear" # com.project1.logic:LOGIC:1.0-SNAPSHOT, C:\Project1\pom.xml, line 6, column 13
This is how part of my parent pom.xml looks
<modelVersion>4.0.0</modelVersion>
<groupId>com.project1.logic</groupId>
<artifactId>LOGICBACKEND</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
This is how child pom.xml looks
<groupId>com.project1.logic</groupId>
<artifactId>DBAccess</artifactId>
<packaging>ejb</packaging>
<name>DBAccess</name>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.project1.logic</groupId>
<artifactId>DBAccess</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Could anybody help me here to understand what is going wrong here.
Thanks in advance for any help
This simple setup is a good start.
.
├── pom.xml
├── services
| ├── pom.xml
| └── src
| └── main
| └── java
| └── com
| └── stackoverflow
| └── MyEjbService.java
└── application
└── pom.xml
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}-${project.version}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>services</module>
<module>application</module>
</modules>
<dependencies>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>services</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
services/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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>services</artifactId>
<packaging>ejb</packaging>
<name>${project.artifactId}-${project.version}</name>
</project>
application/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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>application</artifactId>
<packaging>ear</packaging>
<name>${project.artifactId}-${project.version}</name>
<dependencies>
<dependency>
<groupId>com.stackoverflow.Q13330930</groupId>
<artifactId>services</artifactId>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
</plugins>
</build>
</project>
You are trying to give the parent pom two functions - that is serving as a parent pom (packaging pom) and being the wrapper ear (packaging ear) - at the same time. To solve your issue you should create another maven module under your parent pom that has packaging ear and uses the maven-ear-plugin to define the output.
I got the similar error:
[ERROR]
[ERROR] Invalid packaging for parent POM sandbox:parent:6.5-SNAPSHOT, must be "pom" but is "jar" # sandbox:parent:6.5-SNAPSHOT
I figured out that the root cause was in parent version defined through properties:
<version>${revision}${changelist}</version>
As soon as I set version without referencing the properties the issue gone:
<version>6.5-SNAPSHOT</version>
Might be a maven bug.

Categories

Resources