I have a large GWT application that I'd like to test through Super Dev Mode.
When running the app with
mvn gwt:run-codeserver
it will compile OK and provide the URL for the server. At this point I fire up my app in a web browser and try to compile it again use the bookmarklets. This second compile brings up a range of memory errors like:
Caused by: java.lang.OutOfMemoryError: Java heap space
...
[ERROR] Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)
So it's no secret that I need to assign more memory to the Java process running the server. What I can't work out is how to do that.
I have the following in my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.maven.version}</version>
<configuration>
<extraJvmArgs>-Xmx2048M -Xms1024M -Xss1024k -XX:MaxPermSize=256M -XX:PermSize=128M</extraJvmArgs>
</configuration>
</plugin>
My MAVEN_OPTS environment variable is set to
MAVEN_OPTS=-Xmx2048M
And I have tried executing maven with
mvn -Dgwt.extraJvmArgs=-Xmx2048M gwt:run-codeserver
I have also tried it with the Oracle JDK and the open source JDK supplied with Fedora.
Nothing makes any difference. What am I doing wrong here?
UPDATE
I can confirm that this is an issue with the Maven plugin, and not the code. Running the project using IntelliJ's built in support for Super Dev Mode allow me to compile and recompile the application just fine. So this boils down to knowing the correct way to increase the memory that the Maven plugin has access too. It is obviously not one of the ways I have tried above...
Ok, so this was my fault. The POM.XML had some settings for the gwt plugin used when compiling against a profile, which had the memory settings configured correctly, and then another set of gwt plugin settings not tied to a profile (which I had not noticed).
So when I was compiling for a specific profile (the app server), everything was fine. The settings defined in the profile were being applied, and everything worked as you would expect. But when I running in superdevmode without any profiles set, the second, less specific settings were being used over and above anything I was setting on the command line.
I ended up debugging the problem using the -X maven flag, which dumps out the configuration actually used by the gwt plugin. If anyone has the same problem, look for the output like the sample below. From this you can tell what setting was finally applied, which you can then use to find out where it is set.
[DEBUG] --- exit fork of org.jboss.pressgang.ccms:pressgang-ccms-ui:1.0-SNAPSHOT for org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1:run-codeserver (default-cli) ---
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1:run-codeserver (default-cli)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<bindAddress>${gwt.bindAddress}</bindAddress>
<codeServerPort>${gwt.codeServerPort}</codeServerPort>
<extraJvmArgs default-value="-Xmx1024m">-Xmx1024m</extraJvmArgs>
<gen default-value="${project.build.directory}/.generated">${gwt.gen}</gen>
<genParam default-value="true">${gwt.genParam}</genParam>
<generateDirectory default-value="${project.build.directory}/generated-sources/gwt"/>
<gwtSdkFirstInClasspath default-value="false">${gwt.gwtSdkFirstInClasspath}</gwtSdkFirstInClasspath>
<inplace default-value="false">${gwt.inplace}</inplace>
<jvm>${gwt.jvm}</jvm>
<localRepository>${localRepository}</localRepository>
<logLevel default-value="INFO">INFO</logLevel>
<module>${gwt.module}</module>
<persistentunitcache>${gwt.persistentunitcache}</persistentunitcache>
<persistentunitcachedir>${gwt.persistentunitcachedir}</persistentunitcachedir>
<pluginArtifacts>${plugin.artifacts}</pluginArtifacts>
<project>${project}</project>
<remoteRepositories>${project.remoteArtifactRepositories}</remoteRepositories>
<style default-value="OBF">${gwt.style}</style>
<version>${plugin.version}</version>
<warSourceDirectory default-value="${basedir}/src/main/webapp"/>
<webappDirectory default-value="${project.build.directory}/${project.build.finalName}">${gwt.war}</webappDirectory>
</configuration>
Related
I use lombok extensively at backend, it's really nice and I hope to integrate it into GWT, so I can take advantage of the magic.
I managed to let gwt-maven-plugin recognize lombok by using the -javaagent:lombok.jar=ECJ vm args to be able to compile successfully, however, I'm not sure how to make it work with GWT super dev mode, as it continues complaining "missing getter method" in my IDE(Intellij IDEA).
Also tried the delombok goal of lombok-maven-plugin but without luck.
Any ideas?
Make sure to delete your workDir before starting gwt:run-codeserver. This directory might contain files from previous (lombok-unaware) compilation attempts.
[INFO] --- gwt-maven-plugin:2.8.0-beta1:run-codeserver (default-cli) # Web ---
[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO] workDir: C:\Users\jzaruba\AppData\Local\Temp\gwt-codeserver-1653004051676437159.tmp
This is what my mvn-gwt-codeserver.bat looks like:
call mvn clean dependency:properties gwt:run-codeserver %*
(I added dependency:properties because my gwt-maven-plugin configuration refers to Lombok via project dependency: ${org.projectlombok:lombok:jar}, i.e. no static path.)
And if you don't like launching the codeserver from command line, this is how "VM arguments" in my "GWT Codeserver" launch configuration look like:
-javaagent:path/to/lombok.jar=ECJ
I have a scala project which I've been running fine inside IntelliJ with a Run/Debug configuration set to Application, and now I'd like to create a jar to run it using 'java -jar .jar'. This is a maven project, not SBT.
I have three modules, and the top module which includes all other modules has an reference.conf in the resources folder. It's a minimal application.conf, not a lot of settings. Another one of the modules has its own reference.conf.
I created an artifact based on my top module, and I build it to create a jar. When I execute it with java
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.se.pd.Main.main(Main.scala)
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:145)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:151)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:206)
at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:168)
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:504)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:141)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:118)
at com.se.pd.ServiceMain$class.$init$(ServiceMain.scala:25)
at com.se.pd.Main$.<init>(Main.scala:17)
at com.se.pd.Main$.<clinit>(Main.scala)
When I unzip the file, I see the merged reference.conf in the root dir.
What am I missing? Do I need to do something specific when I create my ActorSystem? I tried deleting all of my config files and running with all defaults, and it still didn't work, although in that case the error changed from complaining about "akka.version" to complaining about "akka". So it feels liek somehow I'm just not loading the akka defaults?
I fixed it for my purposes, but it doesn't really clarify to me what the issue is.
My fix (IntelliJ IDEA specific) was to change the artifact from:
"extract to target JAR"
to
"copy to output directory and link via manifest"
I suppose something gets lost when I create a big fat jar.
--
I just wanted to add a better solution to create a "fat jar" with maven. But I can't take credit, since it looks like the Akka page linked below by Zoltan now suggests the same solution, and in all honesty I cannot remember where I found this. I may have run into the updated page at some point in the past. Please consult that link for much better information.
So:
Use the maven shader plugin to create the fat jar
Then make sure you merge the configuration files:
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>myMainClass</mainClass>
</transformer>
Using that configuration, I can successfully build fat jars.
A newbie question on Maven - Surefire - Eclipse - JUnit
I have configured the maven-surefire-plugin in the pom file of my project to pass some additional JVM arguments as below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>-d64 -Xms128m -Xmx4096m -XX:PermSize=512m -Duser.timezone=UTC -XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
When I run a test case of this project from Eclipse as Run As->JUnit Test, though the classpath is correctly set, the additional arguments specified in the argLine are not included in the invocation. I have to go and manually key in the arguments under the relevant Debug Configurations. I don't quite understand how JUnit is aware that it needs to put jars of the test scope on the classpath and in some way means that JUnit tool in Eclipse is aware of Maven via M2E? If so, how can we make it also read argLine. I know this sounds very specific - but how do others manage in similar situations?
Thanks in advance!
Eclipse JUnit Launcher (choose Run As -> JUnit Test) is a independent test runner which has its own pre-defined build and running life cycle and has nothing to do with Maven, it will not pick up your pom magically and read in the surefire configuration and use them to drive the test running.
If your project is imported as an existing Maven project, use Maven (choose Run as -> Maven test) launch your JUnit test which will pick up and use the surefire configuration. This is exactly same as running mvn test from commandline, it only output run log in console and you will not able to use the nice red & green JUnit UI window.
Hope this make sense.
How does one increase the heap size of the m2e Eclipse plugin? Basically, I'm trying to run an automated integration test using Cargo and Selenium under STS (SpringSource's version of Eclipse) with pre-installed m2e (the popular Maven plugin for Eclipse).
Whenever I run
mvn verify
I get the infamous java.lang.OutOfMemoryError: Java heap space... 63M/63M. So I made some research first. Increase the memory via MAVEN_OPTS, Eclipse.ini / STS.ini, Run Configurations, and even via the Maven plugins thru the pom.xml. Nothing changed. Same error and same amount of memory 63M/63M.
I know my project works. The POM is correct. Why? Because when I run the same command using a stand-alone Maven. The integration test with Selenium and Cargo works. In fact here's the latest output (3 minutes ago):
[INFO] [beddedLocalContainer] Jetty 8.x Embedded is stopped
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 minutes 24 seconds
[INFO] Finished at: Wed Oct 26 14:08:16 CST 2011
[INFO] Final Memory: 70M/149M
[INFO] ------------------------------------------------------------------------
I'm not asking how to increase the memory in stand-alone Maven command. I'm specifically asking how to increase the heap size for m2e.
Note: By default the m2e Eclipse plugin does not have shortcut to the "verify" goal. You have to create a new one via Run Configuration (which does not have an Args tab, fyi).
When working with the Maven 2 plugin, setting java options in eclipse.ini or MAVEN_OPTS environment variable will have no effect on your build. You need to add some command line args via the "Edit Configuration and launch" dialog in Eclipse.
"Run As" > "Maven Build", click on the "JRE" tab, enter VM args e.g.
-Xms128M -Xmx512M
As a follow-on to the already accepted answer, when you invoke "mvn" on the command-line, you are really invoking the mvn.bat (or mvn.sh) wrapper script. It is this wrapper script that uses the MAVEN_OPTS env variable when kicking off the actual maven jvm.
m2e, on the other hand, wants more control over how the maven jvm is kicked off, so it does this directly without the wrapper. This is why you add your memory settings directly to your m2e run/debug configuration VM arguments, rather than using MAVEN_OPTS.
If you want m2e to pass what you already have in MAVEN_OPTS to the maven jvm, in the "Edit Configuration and launch" dialog in Eclipse:
"Run As" > "Maven Build", click on the "JRE" tab, enter VM args e.g.
${env_var:MAVEN_OPTS}
You can add in your pom.xml your memory settings:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
...
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
...
</configuration>
</plugin>
The description of all maven-compiler-plugin parameters is here: link
Have you tried setting the MAVEN_OPTS environment variable for your run configuration?
MAVEN_OPTS="-Xmx768M -XX:MaxPermSize=128m"
Might be you'll have to edit your system environment variables if setting it in the run configuration doesn't help. See here or here
I've faced a similar issue. Create a file named mavenrc_pre.bat on windows or .mavenrc on linux in your home folder and set your maven_opts as you wish in it.
It is working with m2e bundled with Eclipse Indigo.
In Eclipse I imported a maven-based project which uses maven jetty plugin. If I run mvn jetty:run from command line, everything works fine. If I add a run configuration in Eclipse and try to run it, I get the error message:
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/eugene/.m2/repository), central (http://repo1.maven.org/maven2)] -> [Help 1]
In the Eclipe run configuration, I use:
Base directory: ${project_loc}
Goal: jetty:run
Maven Runtime: External
I read the [Help1] page. I don't have pluginGroup settings in maven configuration files, but I have the jetty plugin mentioned in pom.xml, so I guess everything should be fine (especially because everything works in command-line). I tried to "Run as > Maven clean" in Eclipse before executing the jetty run configuration, but it didn't help. Project compiles and passes all tests, only jetty:run does not work in Eclipse.
Please help, I'm an Eclipse & Maven newbie. Thanks in advance.
It does not work for me from command-line either.
Can you check if it works after adding the following in settings.xml as documented?
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>
Also note that there are two different versions of the plugin - the older maven jetty plugin and the newer jetty maven plugin.
I met this problem too, an easier way to solve this is to edit your pom.xml, add following plugin:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.8.v20121106</version>
</plugin>
...
</plugins>
</build>
...
</project>
Note:
jetty-maven-plugin is used for jetty version 7 and above, if you want jetty version 6, you should use maven-jetty-plugin
for the version, you may want to have a look at here and here for your desired version's full name.
I apologize for wasting your time. Now I looked through maven warnings which appeared in Eclipse console after I ran the run configuration. I noticed
[WARNING] Failed to retrieve plugin descriptor for Plugin [org.mortbay.jetty:maven-jetty-plugin]: null
so it became obvious why it couldn't recognize jetty: prefix. Couple of lines above I saw a bunch of warnings about missing plugin versions. So I added a version specification for the jetty plugin (<version> entry in pom.xml) and it solved the problem. I forgot a common rule that if something breaks the first thing to check is warnings you get.
I've got this issue in eclipse after importing an appengine project.
The target:
mvn appengine:devserver
The error:
[ERROR] No plugin found for prefix 'appengine' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/averasko/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
The problem was in the incorrect base directory in the eclipse run configuration. When maven does not see a pom.xml file and is asked to run some non-standard target if fails like this as it don't know anything about the plugin that defines the target.
The solution is to correct the base directory to wherever your pom.xml file resides.
if you following this tutorial:
http://tapestry.apache.org/creating-the-skeleton-application.html
don't forget to follow this one crucial instruction:
Change into the newly created directory, and execute the command: