Maven Compilation Failure but no errors found - java

I'm running a maven build in Java 8, using compatibility target Java 6. When I try to build with Maven in Eclipse (just this project mind you, all other projects in my workspace build just fine), I get a compilation failure from maven, but maven doesn't list any actual errors except a generic MojoFailureException. When I compile through eclipse itself (using ANT or straight Java, there are no compilation errors). Also when I build on a remote machine using Jenkins and the same source code, there also are no problems using maven. It's definitely a local problem and I can't quite figure it out.
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) #
DataAdapterFB1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 58 source files to C:\Users\user\Desktop\GitRepo\FB1DataAdapter\code\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.460 s
[INFO] Finished at: 2018-07-18T08:20:37-04:00
[INFO] Final Memory: 11M/489M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project DataAdapterFB1: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project DataAdapterFB1: Compilation failure
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1165)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 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/MojoFailureException
Relevant compiler plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<executable>${JAVA_6_HOME}\bin\javac.exe</executable>
<compilerArguments>
<bootclasspath>${JAVA_6_HOME}\jre\lib\rt.jar</bootclasspath>
</compilerArguments>
<fork>true</fork>
</configuration>
</plugin>

I have the same problem with using JDK 11 to build a Maven project that targets Java 7. Try removing <fork>true</fork> (or set it to false instead), and that should fix it. (h/t to https://stackoverflow.com/a/39657410/278800)
I don't actually know what the root cause is, though. My guess is that some part of the java environment isn't being passed to the forked compile process, like e.g. JAVA_HOME. Or maybe it's because I'm using jenv to set my java version, and that doesn't work with the forked process.

I was working on a legacy project and I came across the same issue. Steve K's answer shed some light for me as well.
Here is the maven-compiler-plugin section in my project's pom.xml
I'm using IntelliJ IDEA with built in maven and JDK8 in a Windows environment.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<executable>${jdk.home}/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
I'm able to get the compiler running by making the value of <fork>true</fork> to false.
The reasoning behind
If the flag is false, Maven will use the same JVM process that brought up its process to do the compilation, which is fine for me as I am using Java 8 to bootstrap my Maven process.
If the flag is true, maven will try to fork (create) a new JVM process to do the job, and it will use the javac compiler defined in the <executable> section to do so. In my case, there is a ${jdk.home} variable that needs to be injected before running the Maven build. Clearly someone in our team forgot to tell the new joiner regarding for this setup.
There is some performance penalty of making the <fork> flag false though, so the ideal way is to leave it true but make sure the path in <executable> is valid.
https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#fork

Related

How to fix an error from the gwt when deploying an application in java 8 with google-app-engine

With the incoming restriction of app engine to deploy applications with java 7, I need to switch to java 8 my application and deploying it creates errors related to the gwt.
I've tried to change the versions of the gwt plugin, from 2.6.1 to 2.8.2 and 2.8.0.
I've also tried to add dependencies according to other posts on the subject of gwt errors but it didn't change anything.
Finally I tried to deploy the application without compiling the gwt project with this command :
clean install -Dgwt.compiler.skip=true package appengine:update
The app was successfully deployed but doesn't work so I still need to find a solution.
Here are parts of my pom.xml file
<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">
...
<properties>
<appId>sandaya-dev</appId>
<appVersion>9</appVersion>
<module>default</module>
...
<gwt-plugin.version>2.6.1</gwt-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-plugin.version}</version>
<configuration>
<compileTargets>
<value>com.insightos.apps.sandaya.InsightOS</value>
</compileTargets>
<compileSourcesArtifacts>
<compileSourcesArtifact>com.insightos.ui:UI</compileSourcesArtifact>
<compileSourcesArtifact>com.insightos.leisure:LeisureViews</compileSourcesArtifact>
<compileSourcesArtifact>com.insightos.data:GenericDao</compileSourcesArtifact>
<compileSourcesArtifact>com.insightos:Utils</compileSourcesArtifact>
<compileSourcesArtifact>com.insightos.leisure.data:LeisureDao</compileSourcesArtifact>
<compileSourcesArtifact>com.insightos.data:GA</compileSourcesArtifact>
</compileSourcesArtifacts>
<module>com.insightos.apps.sandaya.InsightOS</module>
</configuration>
</plugin>
...
</plugins>
...
</build>
Here is the command I give to deploy to appengine
-X clean install appengine:update
And here are the errors I'm getting from the deployment (I truncated some lines because too long for Stackoverflow) :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.134 s
[INFO] Finished at: 2018-12-25T12:29:25+01:00
[INFO] Final Memory: 71M/817M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.6.1:compile (default) on project Sandaya: Command [[
...
[ERROR] ]] failed with status 1
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.6.1:compile (default) on project Sandaya: Command [[
/bin/sh -c /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/bin/java -Xmx1024m -XX:MaxPermSize=256m -classpath /Users/martijn2/Documents/oxygen-workspaces/acsi/sandaya/target/classes:/Users/martijn2/Documents/oxygen-workspaces/acsi/sandaya/src/main/java:/Users...
]] failed with status 1
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.codehaus.mojo.gwt.shell.ForkedProcessExecutionException: Command [[
/bin/sh -c /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/bin/java -Xmx1024m -XX:MaxPermSize=256m -classpath /Users/...
]] failed with status 1
at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo$JavaCommand.execute(AbstractGwtShellMojo.java:485)
at org.codehaus.mojo.gwt.shell.CompileMojo.compile(CompileMojo.java:446)
at org.codehaus.mojo.gwt.shell.CompileMojo.doExecute(CompileMojo.java:351)
at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo.execute(AbstractGwtShellMojo.java:172)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 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
I expect the build to be a success and not to have these errors, and to obtain a working application deployed to app engine in Java 8.
Thanks by advance for any help

MojoFailureException caused by charsetName on Maven Archetype

When I try to run the command mvn archetype:create-from-project for my WAR project, this exception is showed after the reading of a .java file:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project ConfiguradorWAR: charsetName -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project ConfiguradorWAR: charset
Name
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:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
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:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
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: charsetName
at org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:285)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
The default project encode is Cp1252, I already tried UTF-8 and ISO-8859-1, also edited the encode option from the project and eclipse preferences. On pom.xml:
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
</properties>
and
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.2</version>
<configuration>
<defaultEncoding>${project.build.sourceEncoding}</defaultEncoding>
<encoding>${project.build.sourceEncoding}</encoding>
<archetypeArtifactId>archetype-wsjpa</archetypeArtifactId>
<archetypeGroupId>br.com.example</archetypeGroupId>
<archetypeVersion>1.0</archetypeVersion> <archetypeFilteredExtentions>java,xml</archetypeFilteredExtentions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
The best advice I got from my co-workers was try to replace all the characters with accent in the whole project. I have an EJB project with Cp1252 encode as default that worked on the first try.
Thank you in advance and sorry for my bad english.
After exhaustively exercite every param possible for the command line I found out the right one.
You should create your archetype like this:
mvn archetype:create-from-project -Darchetype.encoding=ISO-8859-1
As you can see on Maven Archetype Plugin Docs you should use the "User property archetype.encoding".
Any other parameter name will fail.
It worked for me!
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
I needed to add the above. Also I ran mvn clean before running mvn archetype:create-from-project

maven-release-plugin [ERROR] fatal: pathspec '' did not match any files

I'm trying to do a release of my OSS library, but I keep running in to a strange issue with the maven-release-plugin. This used to work fine. I've probably updated either Maven or Git but I can't seem to find the right combination to get things working again for the release.
Has anyone run into this issue, and does anyone know of a solution? I'm using the Maven Shade Plugin (which is what is creating the dependency-reduced-pom.xml files in the build.)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:27 min
[INFO] Finished at: 2015-11-04T08:23:07-05:00
[INFO] Final Memory: 111M/1039M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project rewrite-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-add command failed.
[ERROR] Command output:
[ERROR] fatal: pathspec 'config-prettyfaces/dependency-reduced-pom.xml' did not match any files
[ERROR] -> [Help 1]
The dependency-reduced-pom.xml, as I understand it, is a temporary file used while merging dependencies into an uber-jar, and should not be committed, so I'm confused why maven is trying to add this file at all.
Thanks for any help.
I figured it out, at least a workaround:
Using 'checkModificationExcludes" configuration option of the maven-release-plugin to exclude the dependency-reduced-pom.xml seems to work around the issue, though I'm not sure this is exactly what the property was intended for (the documentation is unclear):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>dependency-reduced-pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>

Maven build error - Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5

I am trying to build project using Maven. Unfortunately I have no experience with maven so I am a bit helpless. It is most likely caused by the riak submodule. Here is the github repo with code: YCSB
My system:
Apache Maven 3.2.2 (NON-CANONICAL_2015-04-01T06:56:20_mockbuild; 2015-04-01T08:56:20+02:00)
Maven home: /usr/share/maven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc21.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.1.5-100.fc21.x86_64", arch: "amd64", family: "unix"
Maven stack trace:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project ycsb: Failed to create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project ycsb: Failed to create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
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:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
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: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 create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:541)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.plugin.assembly.archive.ArchiveCreationException: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.addModuleArtifact(ModuleSetAssemblyPhase.java:337)
at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.addModuleBinaries(ModuleSetAssemblyPhase.java:231)
at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase$1.accept(ModuleSetAssemblyPhase.java:140)
at org.apache.maven.plugin.assembly.model.Assemblies.forEachModuleSet(Assemblies.java:40)
at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.execute(ModuleSetAssemblyPhase.java:126)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:178)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:484)
... 21 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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :ycsb
I have no idea what it means so I guess you are my only hope :D
EDIT:
After adding plugin suggested by Subodh Joshi:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project binding-parent: Failed to create assembly: Error creating assembly archive jar-with-dependencies: You must set at least one file.
EDIT2:
mvn compile works fine, but mvn package fails with above error.
You have to add maven-assembly-plugin in your pom.xml file
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.test.MainClassName</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase> <!-- packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
When I trying to work with Netbeans 12.0 OpenJDK 15, I needed import some library projects (.jar) that I developed using OracleJDK 8u231 for some code testings; the result was similiar to the question:
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-assembly)
on project rgbfw-as-core-db: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single
failed: An API incompatibility was encountered while executing
org.apache.maven.plugins:maven-assembly-plugin:2.6:single: java.lang.ExceptionInInitializerError: null
For me, the solution was update the version of the "maven-compiler-plugin" and "maven-assembly-plugin" on my library projects(.jar) before make new run of "Clean and build" of the Netbeans Project explorer.
Current versions:
maven-compiler-plugin(3.8.1)
maven-assembly-plugin(3.3.0)
Do you have the dependecy for it in the pom.xml?
note the error its from maven-assembly-plugin:2.5.5
go to https://mvnrepository.com/ and search for "maven-assembly-plugin"
pick the right version 2.5.5 (or better ) and copy it to your
list in your pom file
If you have a similar plugin under your in your pom file...well
delete it and voila
Go to https://mvnrepository.com/ and search for "maven-assembly-plugin"
pick the right version 2.5.5 (or better ) and copy it to your
<dependencies> list in your pom file
Delete the plugin under your <plugins> in your pom file if its the same version as the dependency

java.lang.OutOfMemoryError: Java heap space in Maven

When I run maven test, java.lang.OutOfMemoryError happens. I googled it for solutions and have tried to export MAVEN_OPTS=-Xmx1024m, but it did not work.
Anyone know other solutions for this problem? I am using maven 3.0
Paste the error message here when run mvn test -e
Failed tests:
warning(junit.framework.TestSuite$1)
testDefaultPigJob_1(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
testDefaultPigJob_2(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
Tests run: 11, Failures: 3, Errors: 0, Skipped: 0
10/11/01 13:37:18 INFO executionengine.HExecutionEngine: Connecting to hadoop fi
le system at: file:///
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.063s
[INFO] Finished at: Mon Nov 01 13:37:18 PDT 2010
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
5:test (default-test) on project dw.pig: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports fo
r the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project
dw.pig: There are test failures.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures
.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugi
n.java:629)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:195)
... 19 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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
When I run maven test, java.lang.OutOfMemoryError happens. I google it for solutions and have tried to export MAVEN_OPTS=-Xmx1024m, but it did not work.
Setting the Xmx options using MAVEN_OPTS does work, it does configure the JVM used to start Maven. That being said, the maven-surefire-plugin forks a new JVM by default, and your MAVEN_OPTS are thus not passed.
To configure the sizing of the JVM used by the maven-surefire-plugin, you would either have to:
change the forkMode to never (which is be a not so good idea because Maven won't be isolated from the test) ~or~
use the argLine parameter (the right way):
In the later case, something like this:
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
But I have to say that I tend to agree with Stephen here, there is very likely something wrong with one of your test and I'm not sure that giving more memory is the right solution to "solve" (hide?) your problem.
References
Maven 2 Surefire Plugin
Classloading and Forking in Maven Surefire
For those new to Maven (like me) here is the whole config that goes in the build section of your pom. Cheers.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</build>
The chances are that the problem is in one of the unit tests that you've asked Maven to run.
As such, fiddling with the heap size is the wrong approach. Instead, you should be looking at the unit test that has caused the OOME, and trying to figure out if it is the fault of the unit test or the code that it is testing.
Start by looking at the stack trace. If there isn't one, run mvn ... test again with the -e option.
To temporarily work around this problem, I found the following to be the quickest way:
export JAVA_TOOL_OPTIONS="-Xmx1024m -Xms1024m"
I have solved this problem on my side by 2 ways:
Adding this configuration in pom.xml
<configuration><argLine>-Xmx1024m</argLine></configuration>
Switch to used JDK 1.7 instead of 1.6
As mentioned in the top answers, as Surefire is creating a new JVM to run your tests, you want to pass that -Xmx1024m to the new JVM instead of the JVM where you start mvn test.
Just wanted to add that you can do that in your command like
mvn test -DargLine="-Xmx1024m"
It has equivalent effect with adding the JVM option to the Surefire plugin's configuration in pom.xml:
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
In order to resolve java.lang.OutOfMemoryError: Java heap space in Maven, try to configure below configuration in pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<argLine>-XX:MaxPermSize=500M</argLine>
</configuration>
</plugin>
Not only heap memory. also increase perm size to resolve that exception in maven use these variables in environment variable.
variable name: MAVEN_OPTS
variable value: -Xmx512m -XX:MaxPermSize=256m
Example :
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=500m"

Categories