2

It appears m2eclipse is not recognizing my $M2_OPTS variable.

I can run the same build outside of eclipse fine (with cranked up heapsize):

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 51 seconds
[INFO] Finished at: Tue Nov 10 00:00:02 EST 2009
[INFO] Final Memory: 72M/187M
[INFO] ------------------------------------------------------------------------

But when I run this with m2eclipse I always run out of memory:

[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Trace
  java.lang.OutOfMemoryError: Java heap space
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
    ...
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 27 seconds
[INFO] Finished at: Mon Nov 09 23:56:32 EST 2009
[INFO] Final Memory: 43M/81M
[INFO] ------------------------------------------------------------------------

Any ideas?

SOLUTION : Add the mem args to the Installed JREs tab of the Java preferences.

cwash
  • 4,185
  • 5
  • 43
  • 53

1 Answers1

3

There is currently an issue about this, see MNGECLIPSE-1182, and a workaround:

... you can specify default JVM arguments in Window / Preferences / Java / Installed JREs.

But actually, this comment is confusing me:

[ It appears as though the current m2eclipse plugin still honors the M2_OPTS environment variable when using an external maven installation.

So I just defined both of them: MAVEN_OPTS for running mvn from command prompts and M2_OPTS for running maven from m2eclipse. E.g. set M2_OPTS=-Xmx256M -XX:MaxPermSize=128M

I'm using Maven 2.1.0 and Maven Integration for Eclipse version 0.9.9.200907071528 with Eclipse Galileo. ]

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Hmmm. Good point. I looked again, and I had defined $MAVEN_OPTS, not $M2_OPTS. After I added a $M2_OPTS, things seem to work out the same way. So I'm equally as baffled. I cleared the Maven settings and everything and still no dice. – cwash Nov 10 '09 at 06:17
  • I cranked the mem args on the installed VM and everything worked. Thanks for the help. – cwash Nov 10 '09 at 06:21
  • I followed this same answer to specify other MAVEN_OPTS arguments (keystore and truststore for my HTTPS Artifactory server) and it fixed a similar issue where JARs were not being downloaded from Artifactory because Eclipse was not using MAVEN_OPTS to communicate with Artifactory. – BennyMcBenBen Jan 18 '12 at 17:50