STS with Maven - java.lang.OutOfMemoryError: Java heap space


I’ve recently started using SpringSource Tool Suite (STS) for a large Flex on Java project, In the recent configuration I used eclipse to code and launched Maven using command line. STS provides a built in Maven launcher which really makes more sense to use (STS use m2eclipse to fully integrate maven with eclipse). The only problem is that once I tried to run mvn clean install I ran into the good old heap space issue:<div>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%">java.lang.OutOfMemoryError: Java heap space
at java.io.BufferedWriter.(BufferedWriter.java:87)
at java.io.BufferedWriter.(BufferedWriter.java:70)
at java.io.PrintStream.init(PrintStream.java:83)
at java.io.PrintStream.(PrintStream.java:100)
at java.io.PrintStream.(PrintStream.java:62)
at org.aspectj.weaver.bcel.LazyClassGen.toLongString(LazyClassGen.java:764)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1837)
at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1755)
at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1515)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1322)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:435)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:371)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:358)
at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:98)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:652)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:392)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1007)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:268)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:182)
at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
at org.aspectj.tools.ajc.Main.run(Main.java:355)
at org.aspectj.tools.ajc.Main.runMain(Main.java:234)
at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:378)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
</pre><div>
</div><div>The solution obviously is to increase the maximum heap size which is represented by the JVM -Xmx argument. Now there are a number of places you can find this argument (STS.ini is one of them) , but here’s the one place I found that really makes the difference. </div><div>
</div><div><ul><li>Goto the ‘Run Configurations’ popup of the current maven run you are trying to use (can be accesed by right clicking your project and selecting ‘Run As’)</li><li>Select your current run under ‘Maven Build’ in the tree</li><li>Select the the JVM tab and add your requested -Xmx settings (I chose -Xmx512m)</li><li>Press ‘Apply’ and ‘Run’</li></ul></div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>
</div><div>You should now be able to run your Maven project.</div>

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com