I am trying to execute grails run-app and getting out of memory error.
[groovyc] java.lang.OutOfMemoryError: Java heap space
I have set grails_opts as: GRAILS_OPTS="-XX:MaxPermSize=2048m -Xmx4096M -server"
Tried various options for JAVA_OPTS also but still getting outofmemory error.
Related
I am running grails 3.2.1 and want to create Swagger-documentation for my REST endpoints. I added the SwaggyDoc-plugin to the dependencies in my build.gradle script by adding:
compile "org.grails.plugins:swaggydoc-grails3:0.28.0"
And configure it by https://rahulsom.github.io/swaggydoc/ .
In IntelliJ I see the Swaggydoc-dependency added to my list of libraries.
After starting my Grails-application via the grails run-app command and opening my application by entering http://localhost:8080/api/ I get an swagger-ui index.html, but I find error in console log(see in image).
console log errors
And this exceptions in grails.
ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[grailsDispatcherServlet] - Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[Digest Input Stream] MD5 Message Digest from SUN
Answer
When we create grails application inside intellij we will get the following dependency inside application.yaml file.
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.11.6"
We need to replace this with the following :
runtime "org.grails.plugins:asset-pipeline"
This error will be resolved.
Every once in a while I have seen this error when issuing the grails run-app target:
| Error Error executing script RunApp: : IOException in C:\Users\user\Dropbox\Code\Projects\qotd\target\work\web.xml.tmp - java.io.FileNotFoundException:C:\Users\user
\Dropbox\Code\Projects\qotd\target\work\web.xml.tmp (Access is denied) (Use --sta
cktrace to see the full trace)
and so far it appears I can always get around it by issuing grails run-app again. If possible I would like to know what is the mechanism causing this error and why does it seem to disappear/correct by itself. Thanks.
Edit: Is it possible that this error is generated because since I keep my project in my Dropbox folder, I may sometimes invoke the grails run-app target while something in Dropbox is still syncing?
I recently encountered the following error running a Grails application that will utilmately be a quartz job triggered by a cron (currently attached to a controller for development):
2014-11-21 12:37:34,538 [quartzScheduler_Worker-1] ERROR listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job
Message: java.lang.OutOfMemoryError: GC overhead limit exceeded
I want to increase the Heap speace but I'm not sure of the correct way to do it for my grails version(2.2.4).
Do I create a GRAILS_OPT environment variable or do I use grails.project.fork?
I will assume that you are needing to change these settings for development and doing so is accomplished using GRAILS_OPT environment variable. Consult instructions for your OS on how to do so.
From the Grails documentation:
It's often useful to provide custom arguments to the JVM when running
Grails commands, in particular with run-app where you may for example
want to set a higher maximum heap size. The Grails command will use
any JVM options provided in the general JAVA_OPTS environment
variable, but you can also specify a Grails-specific environment
variable too:
export GRAILS_OPTS="-Xmx1G -Xms256m -XX:MaxPermSize=256m"
grails run-app
I'm using Grails 2.3.8
I've created a default app using
grails create-app testapp
When I run:
grails runApp
I get the following issue:
| Configuring classpath
| Error Error executing script RunApp: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.eclipse.aether.internal.impl.Slf4jLoggerFactory$Slf4jLoggerEx.debug(Slf4jLoggerFactory.java:163)
at org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider.newLocalRepositoryManager(DefaultLocalRepositoryProvider.java:142)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.newLocalRepositoryManager(DefaultRepositorySystem.java:421)
at grails.util.BuildSettings.doResolve(BuildSettings.groovy:513)
at grails.util.BuildSettings.doResolve(BuildSettings.groovy)
at grails.util.BuildSettings$_getDefaultBuildDependencies_closure17.doCall(BuildSettings.groovy:774)
at grails.util.BuildSettings$_getDefaultBuildDependencies_closure17.doCall(BuildSettings.groovy)
at grails.util.BuildSettings.getDefaultBuildDependencies(BuildSettings.groovy:768)
at grails.util.BuildSettings.getBuildDependencies(BuildSettings.groovy:673)
| Error Error executing script RunApp: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
I tried running:
grails dependency-report
but I get the same issue.
java -version
gives:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Not sure if this is your problem, but I vaguely recall there being some problems with Groovy and the earlier versions of Java 7. I'd recommend moving to the most recent. I have no problems with 2.3.8 and jdk1.7.0_55 (most recent at time of writing).
Have you looked for conflicting versions of slf4j? Try running Grails dependency-report.
There are a few other SO questions that indicate this to be a cause of issue. Eg: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
sl4j error in weblogic when deploying grails application war
One thing that can help in debugging situations like this is doing:
export JAVA_OPTS="-verbose"
You can then see which slf4j JAR is being loaded by the JVM, but yes there is undoutably some conflicing slf4j JAR on your classpath
There was an instance of slf4j in:
/Library/Java/Extensions/
Moving that out seems to have fixed the problem.
I am trying to generate HTML reports from txt format reports that were generated after executing junit test cases. On running ant command with build.xml in proper location, I am getting below error message
java.lang.OutOfMemoryError: Java heap space
I tried increasing heap space by ANT_OPTS=-Xmx1024m command.
Still facing the same issue.
Use export JAVA_OPTS=-Xmx1024m before starting Ant, because ANT_OPTS may be overriden by JAVA_OPTS if they are set system wise