I got this error while trying to build an ear using Maven.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) on project cargooceanear: Failed to initialize ear modules: Unknown artifact type[tes t-jar] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) on project cargooceanear: Failed to i nitialize ear modules at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to initialize ear modules at org.apache.maven.plugin.ear.AbstractEarMojo.execute(AbstractEarMojo.java:240) at org.apache.maven.plugin.ear.GenerateApplicationXmlMojo.execute(GenerateApplicationXmlMojo.java:85) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more Caused by: org.apache.maven.plugin.ear.UnknownArtifactTypeException: Unknown artifact type[test-jar] at org.apache.maven.plugin.ear.util.ArtifactTypeMappingService.getStandardType(ArtifactTypeMappingService.java:151) at org.apache.maven.plugin.ear.EarModuleFactory.newEarModule(EarModuleFactory.java:74) at org.apache.maven.plugin.ear.AbstractEarMojo.execute(AbstractEarMojo.java:230) ... 22 more
issue: maven-ear-plugin gives your an error:
[INFO] Failed to initialize ear modules Embedded error: Unknown artifact type[zip]
cause: zip or unsupported file in transitive dependencies
solution: in windows, open cmd, cd root directory of your the project first, then type mvn dependency:tree
in the cmd, to find transitive dependencies that has conflict with marven-ear-plugin.
e.g. unknown zip +- com.sun.xml.ws:samples:zip:2.2.10:compile means
<groupId>com.sun.xml.ws</groupId>
<artifactId>samples</artifactId>
e.g. change ear pom:put exclusion in your dependency
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
...
<exclusions>
<exclusion>
<groupId>com.sun.xml.ws</groupId>
<artifactId>samples</artifactId>
</exclusion>
...
</exclusions>
</dependency>
same for +- com.sun.xml.ws:release-documentation:zip
Basically this error is due to the dependencies or transitive dependencies with the type "test-jar".
e.g.
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-data</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
Option A: If "test-jar" is found in a dependency in the pom.xml then add the "test-jar" goal to maven-jar-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
.............
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Option B: If "test-jar" is found in a transitive dependency then this must be excluded in the pom.xml to fix this error.
<dependency>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>${myartifact-release-version}</version>
<type>ejb</type>
<exclusions>
<exclusion>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-data</artifactId>
</exclusion>
</exclusions>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With