2

So i'm getting this error when trying to Clean Install with Maven. I've attempted increasing MAVEN_OPTS with Xmx-512m or w/e it was called, similarly fiddled with Eclipse ini to increase heap space, but all of this to no avail, I keep getting this error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building DiaryAppREST 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ DiaryAppREST ---
[INFO] Deleting C:\Users\Administrator\workspace\DiaryAppREST\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ DiaryAppREST ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Administrator\workspace\DiaryAppREST\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ DiaryAppREST ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\Administrator\workspace\DiaryAppREST\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ DiaryAppREST ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Administrator\workspace\DiaryAppREST\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ DiaryAppREST ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ DiaryAppREST ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:3.0.0:war (default-war) @ DiaryAppREST ---
[INFO] Packaging webapp
[INFO] Assembling webapp [DiaryAppREST] in [C:\Users\Administrator\workspace\DiaryAppREST\target\DiaryAppREST-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Administrator\workspace\DiaryAppREST\WebContent]
[INFO] Webapp assembled in [8913 msecs]
[INFO] Building war: C:\Users\Administrator\workspace\DiaryAppREST\target\DiaryAppREST-0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.019 s
[INFO] Finished at: 2017-02-28T09:52:30+00:00
[INFO] Final Memory: 86M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war (default-war) on project DiaryAppREST: Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it): Java heap space -> [Help 1]
[ERROR] 

I can't understand what is causing this, tried to find information online but can't seem to find this specific problem that anyone else is having. If anyone would be able to help i'd be very much appreciated.

Russiee
  • 101
  • 2
  • 9

2 Answers2

4

Just figured it out,

Firstly, I had set MAVEN_OPTS incorrectly, I had them set as:

set MAVEN_OPTS="Xmx 512m"

After changing this to:

set MAVEN_OPTS="-Xmx512m"

You can also add this line into your profile (.profile, .bash_profile, etc) for this to be set in every terminal you open.

export MAVEN_OPTS="-Xmx512m"

And then went into the directory the project was in using CMD, I ran:

mvn clean install -U

This seemed to do the trick and everything went successfully.

Hope this helps anyone else having problems!

Russiee
  • 101
  • 2
  • 9
0

I had the same issue running maven via ant from Jenkins on a Windows box.

The issue was how to pass the memory parameter. Here is the updated ant script showing how to pass the parameter "<jvmarg value="-Xmx1024m" />":

<target name="web.package" depends="init" if="warName">
    <artifact:mvn mavenHome="${maven.home}" failonerror="true" fork="true">
        <jvmarg value="-Dmaven.multiModuleProjectDirectory=$M2_HOME" />
        <jvmarg value="-Xmx1024m" />
        <arg value="package" />
        <arg value="-Pwar" />
        <arg value="-DwarName=${warName}" />
        <arg value="-Denv=${env}" />
        <arg value="-e" />
    </artifact:mvn>
</target>

For info, here is the crash output:

[artifact:mvn] [INFO] Building war: D:\Jenkins\workspace\DEPLOY_SVN\atl_dev_trunk\src\tomcat\target\abc##6_4_6_0.war
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] BUILD FAILURE
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 01:50 min
[artifact:mvn] [INFO] Finished at: 2017-11-09T02:35:50+01:00
[artifact:mvn] [INFO] Final Memory: 99M/247M
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war (default-war) on project abc: Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it): Java heap space -> [Help 1]
David Robson
  • 173
  • 8