Maven Deploy to Nexus Fails When Deploying Artifact with Classifier - maven

All,
I have a Spring Boot Application which needs to be deployed to Nexus as both a library and an executable jar. Spring provides a way to have both using the following bit of code in the POM file.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.3.RELEASE</version>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
This produces the following two JARs.
(a) target/[artifact]-[version].jar
(b) target/[artifact]-[version]-exec.jar
Previous to adding the code to the POM, I am able to deploy artifact (a) to Nexus without issue. However, once I add the code, I get the following exception.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project [artifact-id]: Failed to deploy artifacts: Could not find artifact [group-id]:[artifact-id]:jar:exec:[version]-[iteration] in nexus.ftc.lab ([nexus-url])
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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 deploy artifacts: Could not find artifact [group-id]:[artifact-id]:jar:exec:[version]-[iteration] in nexus.ftc.lab ([nexus-url])
at org.apache.maven.plugin.deploy.DeployMojo.deployProject(DeployMojo.java:284)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:169)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not find artifact [group-id]:[artifact-id]:jar:exec:[version]-[iteration] in nexus.ftc.lab ([nexus-url])
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:171)
at org.apache.maven.plugin.deploy.DeployMojo.deployProject(DeployMojo.java:279)
... 23 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not find artifact [group-id]:[artifact-id]:jar:exec:[version]-[iteration] in nexus.ftc.lab ([nexus-url])
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 25 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact [group-id]:[artifact-id]:jar:exec:[version]-[iteration] in nexus.ftc.lab ([nexus-url])
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:893)
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:1)
at io.takari.aether.connector.AetherRepositoryConnector$PutTask.flush(AetherRepositoryConnector.java:743)
at io.takari.aether.connector.AetherRepositoryConnector.put(AetherRepositoryConnector.java:345)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
... 28 more
To add to the intrigue. I tried building another JAR using more standard code. When I deploy using this, it works fine.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
One more update, when I try the below, it fails with the same exception.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>fat</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

This issue was caused by request filtering limits in an IIS proxy.
By default, the maximum allowed content length was 30 MB. This was blocking my post of a ~90 MB jar file. Increasing the limit to 512 MB fixed the problem.

Related

NPE: Execution copy-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources failed

Note: before someone mark this issue as duplicate please note I have already read and tried solutions suggested in following similar threads which did not work for me:
Maven:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources
and
https://issues.apache.org/jira/browse/MSHARED-223
I see following on my CLI after I execute 'mvn -X clean compile|package':
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources (copy-resources) on project empl-monthly-payslip: Execution copy-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources (copy-resources) on project empl-monthly-payslip: Execution copy-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.PluginExecutionException: Execution copy-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:copy-resources failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Here is the relevant part of my POM file:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<maven.compiler.version>3.6.1</maven.compiler.version>
<maven.assembly.version>3.0.0</maven.assembly.version>
<maven.resources.version>3.0.2</maven.resources.version>
</properties>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.resources.version}</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<includeEmptyDirs>true</includeEmptyDirs>
<resources>
<resource>
<targetPath>${basedir}/src/main/resources</targetPath>
<filtering>false</filtering>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I want to copy all resources (recursively) that are at ${basedir}/src/main/resources folder. Any help/advise greatly appreciated.
Note: I'm using Apache Maven 3.3.9. And have also tried cleaning everything under my ~/.m2/repository and compiling again.

NoClassDefFoundError when using cxf-codegen-plugin with maven

I'm trying to convert wsdl into java using maven and cxf-codegen-plugin but i always get the same error:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (aspsms) on project webapp: org/apache/velocity/context/Context: org.apache.velocity.context.Context -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (aspsms) on project webapp: org/apache/velocity/context/Context
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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: org/apache/velocity/context/Context
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:435)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:260)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:512)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
at org.apache.cxf.tools.wsdlto.core.AbstractGenerator.<init>(AbstractGenerator.java:47)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AbstractJAXWSGenerator.<init>(AbstractJAXWSGenerator.java:30)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AntGenerator.<init>(AntGenerator.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEndGenerators(PluginLoader.java:278)
at org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEndProfile(PluginLoader.java:393)
at org.apache.cxf.tools.wsdlto.WSDLToJava.loadFrontEnd(WSDLToJava.java:64)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:96)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:415)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.apache.velocity.context.Context
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 38 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My mvn version:
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Users/user/Desktop/dev/ses/apps/apache-maven-3.3.9
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
Here is my pom file:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>aspsms</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/generated-source</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/wsdl/aspsmsx2.wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>com.test.service.adapter.aspsms.wsclient</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
The jar files were correctly downloaded in my maven repo. Do you have an advice?
Maybe you can add explicitly the dependency to velocity in the plugin configuration
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>aspsms</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/generated-source</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/wsdl/aspsmsx2.wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>com.test.service.adapter.aspsms.wsclient</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
</plugin>

Inconsistently receiving FORCE_DEPLOY error when Deploying app via jenkins on wildfly 10

When I try to run maven "clean compile install wildfly:deploy" on jenkins for my application, it works fine sometimes and returns a success but sometimes it fails with the below error. The application code did not change but the behavior of the build keeps changing. I did try to restart the wildfly server manually on Amazon Linux ec2 instance to see that it sometimes helps. The same mvn works fine locally when testing the app and deploying on local windows workstation.
NOTE: My Jenkins and Wildfly app server are on the same Amazon Linux EC2 instance. So on the build script, I referred it as localhost.
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha7:deploy (default-cli) on project MedDRA-DataProcessing: Error executing FORCE_DEPLOY: java.util.concurrent.CancellationException: Operation was cancelled -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha7:deploy (default-cli) on project MedDRA-DataProcessing: Error executing FORCE_DEPLOY
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.wildfly.plugin.common.DeploymentExecutionException: Error executing FORCE_DEPLOY
at org.wildfly.plugin.deployment.standalone.StandaloneDeployment.execute(StandaloneDeployment.java:161)
at org.wildfly.plugin.deployment.AbstractDeployment.executeDeployment(AbstractDeployment.java:147)
at org.wildfly.plugin.deployment.AbstractDeployment.doExecute(AbstractDeployment.java:179)
at org.wildfly.plugin.deployment.AbstractAppDeployment.doExecute(AbstractAppDeployment.java:70)
at org.wildfly.plugin.deployment.AbstractDeployment.execute(AbstractDeployment.java:137)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.io.IOException: java.util.concurrent.CancellationException: Operation was cancelled
at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:149)
at org.jboss.as.controller.client.impl.AbstractModelControllerClient.execute(AbstractModelControllerClient.java:80)
at org.wildfly.plugin.deployment.standalone.StandaloneDeployment.execute(StandaloneDeployment.java:153)
... 26 more
Caused by: java.util.concurrent.CancellationException: Operation was cancelled
at org.jboss.threads.AsyncFutureTask.operationCancelled(AsyncFutureTask.java:70)
at org.jboss.threads.AsyncFutureTask.get(AsyncFutureTask.java:267)
at org.jboss.as.controller.client.impl.AbstractDelegatingAsyncFuture.get(AbstractDelegatingAsyncFuture.java:57)
at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:147)
... 28 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
pom.xml has:
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<!-- Deployment on AS from console -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.maven.wildfly}</version>
<configuration>
<hostname>localhost</hostname>
<port>9990</port>
<username>user1</username>
<password>password1</password>
</configuration>
</plugin>
</plugins>
</build>
Have you tried to use other plugin versions then alpha for your plugins? I recommend final versions as it often happes that there can be inconsistencies in alphabuilds

Why does jbehave-maven-plugin give me a NoClassDefFoundError?

I get the following error when I run mvn integration-test -e com.example.mymodule:
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables: Failure in running embeddable: com.example.mymodule.TheStories: Could not initialize class freemarker.ext.beans.BeansWrapper -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.MojoFailureException: Failed to run stories as embeddables
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20)
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.jbehave.core.embedder.Embedder$RunningEmbeddablesFailed: Failure in running embeddable: com.example.mymodule.TheStories
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:130)
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
... 21 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class freemarker.ext.beans.BeansWrapper
at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:69)
at freemarker.core.Configurable.<init>(Configurable.java:139)
at freemarker.template.Configuration.<init>(Configuration.java:142)
at freemarker.template.Configuration.<clinit>(Configuration.java:127)
at org.jbehave.core.reporters.FreemarkerProcessor.configuration(FreemarkerProcessor.java:30)
at org.jbehave.core.reporters.FreemarkerProcessor.process(FreemarkerProcessor.java:21)
at org.jbehave.core.reporters.TemplateableViewGenerator.write(TemplateableViewGenerator.java:267)
at org.jbehave.core.reporters.TemplateableViewGenerator.createReports(TemplateableViewGenerator.java:219)
at org.jbehave.core.reporters.TemplateableViewGenerator.generateReportsView(TemplateableViewGenerator.java:110)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:249)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:237)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213)
at org.jbehave.core.junit.JUnitStories.run(JUnitStories.java:20)
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:121)
... 22 more
When I run mvn dependency:tree -pl com.example.mymodule | grep freemarker I get
[INFO] | +- org.freemarker:freemarker:jar:2.3.19:compile
I used javap to confirm that the class freemarker.ext.beans.BeansWrapper exists in this jar:
javap -classpath C:\Users\CONOR2\.m2\repository\org\freemarker\freemarker\2.3.19\freemarker-2.3.19.jar freemarker.ext.beans.BeansWrapper
Here's the relevant portion of my depdendencies from my pom.xml:
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.9.5</version>
<classifier>resources</classifier>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbehave.site</groupId>
<artifactId>jbehave-site-resources</artifactId>
<version>3.2</version>
<type>zip</type>
</dependency>
Here's my plugin section:
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>3.9.5</version>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>process-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<execution>
<id>embeddable-stories</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>com/example/mymodule/TheStories.java</include>
</includes>
<excludes />
<ignoreFailureInStories>true</ignoreFailureInStories>
<ignoreFailureInView>false</ignoreFailureInView>
<scope>test</scope>
<threads>1</threads>
<metaFilters>
<metaFilter></metaFilter>
</metaFilters>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
I tried this with versions 3.9.5 and 4.0.3, but I get the same error with both versions.
It turns out that the jbehave-maven-plugin was having trouble with log4j. Adding log4j:log4j and org.slf4j:slf4j-log4j as dependencies for the plugin fixed the issue.

How to Generate REST Docs with Enunciate for a Spring-Jersey Project?

I'm struggling with something that I thought is quite simple - to generate documentation for a set of already existing REST services, which are basically just POJOs annotates with JAX-RS annotations. I'm using Jersey as an implementation provider. The REST API is deployed as part of a Spring web application.
I want to generate only the documentation for the REST services POJOs, so my enunciate.xml configuration is something like that:
<?xml version="1.0"?>
<enunciate label="novaglobalapi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.25.xsd">
<api-classes>
<include pattern="com.something.api.rest.*"/>
</api-classes>
<modules>
<docs docsDir="restapi" title="REST API"/>
</modules>
</enunciate>
I've configured my pom.xml as suggested in the enunciate documentation:
<build>
...
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.25</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>enunciate.xml</configFile>
</configuration>
</plugin>
...
</build>
But when I run mvn enunciate:docs, I'm getting the following build error:
[ERROR] Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:docs (default-cli) on project NovaGlobalSSOAPI: Problem assembling the enunciate app. invalid LOC header (bad signature) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:docs (default-cli) on project NovaGlobalSSOAPI: Problem assembling the enunciate app.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Problem assembling the enunciate app.
at org.codehaus.enunciate.DocsMojo.execute(DocsMojo.java:99)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1200(ZipFile.java:31)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:459)
at java.util.zip.ZipFile$1.fill(ZipFile.java:242)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
at java.io.DataInputStream.readFully(DataInputStream.java:178)
at java.util.jar.JarFile.getBytes(JarFile.java:362)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:161)
at java.util.jar.JarFile.getManifest(JarFile.java:148)
at org.codehaus.enunciate.main.Enunciate.scanClasspath(Enunciate.java:409)
at org.codehaus.enunciate.main.Enunciate.doGenerate(Enunciate.java:319)
at org.codehaus.enunciate.ConfigMojo$MavenSpecificEnunciate.doGenerate(ConfigMojo.java:634)
at org.codehaus.enunciate.main.Enunciate$Stepper.step(Enunciate.java:1706)
at org.codehaus.enunciate.main.Enunciate$Stepper.stepTo(Enunciate.java:1738)
at org.codehaus.enunciate.DocsMojo.execute(DocsMojo.java:95)
... 21 more
I can not figure out, what am I doing wrong. Any ideas?
Does it happen if you configure the documentation directory?
<build>
...
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.25</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- the directory where to put the docs -->
<docsDir>${project.build.directory}/docs</docsDir>
<configFile>enunciate.xml</configFile>
</configuration>
</plugin>
...
</build>
Edit: forgot to close docsDir
Use the following code in your maven pom:
<build>
<plugins>
<plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>${enunciate.version}</version>
<configuration>
<sourcepath-includes>
<sourcepath-include>
<groupId>com.your.company.web.rest</groupId>
</sourcepath-include>
<sourcepath-include>
<groupId>com.external</groupId>
<artifactId>external</artifactId>
</sourcepath-include>
</sourcepath-includes>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
With the following property:
<properties><enunciate.version>2.10.1</enunciate.version></properties>
In your maven home make sure you have an xml file called enunciate.xml with the following lines of code:
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.0.0-M.4.xsd">
<title>Your Company REST API</title>
<description package="com.your.company.web.api"/>
<copyright>www.yourcompany.com</copyright>
<api-classes>
<include pattern="com.your.company.web.rest.*"/>
</api-classes>
<modules>
<docs docsDir="src/main/webapp/restapi" title="Your Company REST API"/>
<jackson disabled="true"/>
<swagger basePath="/yourcompany/api/"/>
</modules>
</enunciate>

Resources