I am using http://typesafe.com/stack/ for the first time, and I created simple akka project. My scala version is 2.9.2 I get the following error.
[info] Done updating.
[info] Compiling 1 Scala source to /Users/hrishikeshparanjape/git-public/web-service/target/scala-2.9.2/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.9.2. Compiling...
sbt appears to be exiting abnormally.
The log file for this session is at /var/folders/26/hqgjyf0j7192hmjdsz17f3v80000gn/T/sbt2587622650679130928.log
java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at sbt.CompletionService$$anon$1.take(CompletionService.scala:29)
at sbt.Execute.next$1(Execute.scala:74)
at sbt.Execute.processAll(Execute.scala:77)
at sbt.Execute.runKeep(Execute.scala:57)
at sbt.EvaluateTask$.run$1(EvaluateTask.scala:109)
at sbt.EvaluateTask$.runTask(EvaluateTask.scala:124)
at sbt.Aggregation$$anonfun$7.apply(Aggregation.scala:87)
at sbt.Aggregation$$anonfun$7.apply(Aggregation.scala:85)
at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:87)
at sbt.Aggregation$.runTasks(Aggregation.scala:85)
at sbt.Aggregation$$anonfun$applyDynamicTasks$1.apply(Aggregation.scala:141)
at sbt.Aggregation$$anonfun$applyDynamicTasks$1.apply(Aggregation.scala:136)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:64)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:64)
at sbt.Command$.process(Command.scala:92)
at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:121)
at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:121)
at sbt.State$$anon$1.process(State.scala:154)
at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:121)
at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:121)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.MainLoop$.next(Main.scala:121)
at sbt.MainLoop$.run(Main.scala:114)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(Main.scala:103)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(Main.scala:100)
at sbt.Using.apply(Using.scala:25)
at sbt.MainLoop$.runWithNewLog(Main.scala:100)
at sbt.MainLoop$.runAndClearLast(Main.scala:83)
at sbt.MainLoop$.runLoggedLoop(Main.scala:67)
at sbt.MainLoop$.runLogged(Main.scala:60)
Error during sbt execution: java.lang.OutOfMemoryError: PermGen space
Please help.
Your project needs more memory to be executed (that's what the java.lang.OutOfMemoryError: PermGen space tells you). I have never used the typesafe stack, thus I don't know if it is possible to configure memory parameters directly.
But if you run Linux you can type
env JAVA_OPTS="-Xms512m -Xmx1024m -Xss1M -XX:MaxPermSize=512" <command>
where command is the command to execute your project (probably it is sbt). Of course, you can change the size of the parameters if you need more/less space.
Related
On a remote Windows 10 system sbt failes to start with a NoClassDefFoundError:
C:\WORKBENCH\BPF\my-project>sbt -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT -Dsbt.boot.credentials="C:\WORKBENCH\BPF\my-project\credentials.txt" -Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot -Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier -v
# Executing command line:
"C:\Program Files (x86)\Java\jre1.8.0_321\bin\java.exe"
-Djavax.net.ssl.trustStore="C:\Program Files (x86)\Java\jre1.8.0_321\lib\security\cacerts"
-Djavax.net.ssl.trustStorePassword=changeit
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-cp
"C:\Program Files (x86)\sbt\bin\sbt-launch.jar"
xsbt.boot.Boot
-Djavax.net.ssl.trustStoreType=WINDOWS-ROOT
-Dsbt.boot.credentials=C:\WORKBENCH\BPF\my-project\credentials.txt
-Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot
-Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier
java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
at sbt.xMain.run(Main.scala:46)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
Tried with different SBT versions (1.6.2, 1.5.8, 1.4.9) by changing project/build.properties): The Stack Trace differs depending on the version, but it is always a NoClassDefFoundError.
The SBT version specified in the project is successfully downloaded by the launcher.
I suspect local file permission problems as cause (e.g. due to security policies) therefore i moved the boot and the coursier cache directory. However, this did not bring the desired success.
Does anyone have an idea what the Problem could be?
(I did not do much findings about it.) In my case i could fix it by changing to appropriate java version. Initially i ran with java 18v mistakenly and then changing to java 11v it worked.
I don't have a real diagnosis or causal explanation, but I did solve a similar problem (identical error message, Linux) by clearing out the sbt cache (the .sbt folder within your user directory).
I need to modify KIE Workbench source and I have two issues that are stopping me from building with Maven 3.2.5, one on Windows and one on Linux.
On Windows 7, I am getting an error that says
[deletia...]SNAPSHOT\uberfire-backend-api-0.4.0-SNAPSHOT-sources.jar,
com.google.gwt.dev.Compiler,-logLevel, INFO, -style, OBF, -war,
c:\kie-wb-webapp\target\kie-wb-webapp-6.1.1-SNAPSHOT, -localWorkers, 1,
-strict, -XfragmentCount, -1, -deploy, c:\kie-wb-webapp\target\gwt-symbols-deploy, -gen,
c:\kie-wb-webapp\target\.generated, org.kie.workbench.FastCompiledKIEWebapp]:
Error while executing process. Cannot run program "c:\development\software\jdk\jdk1.7.0_71\jre\bin\java":
CreateProcess error=206, The filename or extension is too long.
So I looked it up and apparently, this is well known limitation since gwt-maven-plugin creates a command-line that is longer than 8191 chars and this is forbidden. So I gave it a shot on Ubuntu.
On Ubuntu,
I am getting:
[INFO] --- gwt-maven-plugin:2.5.1:compile (gwt-compile) # kie-wb-webapp [ERROR] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[ERROR] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
[INFO] Compiling module org.kie.workbench.FastCompiledKIEWebapp
[INFO] Validating units:
[INFO] [ERROR] Errors in 'jar:file:/home/rich/.m2/repository/com/google/guava/guava-gwt/14.0.1/guava-gwt-14.0.1.jar!/com/google/common/primitives/Booleans.java'
[INFO] [ERROR] Line 29: The import java.util.BitSet cannot be resolved
[INFO] [ERROR] Aborting compile due to errors in some input files
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE*
It's really important that I find a workaround to 1 or both of these issues (my guess is that if I clear the command-line issue on Windows, I'll just run into the guava issue again). Also, unless it's absolutely necessary, I can't upgrade to 6.2.x, because this would cause a lot of work for my project.
Has anyone run into this?
If you don't need Java 8 support, you may be able to solve the problem by using an earlier version of the JDK. I believe that you do this by setting JAVA_HOME for your Maven run. You can download a JDK 7 here.
You could also build Guava yourself from HEAD, as the problem has been fixed there but not included in a release. Or you could wait for a 19.0-rc1, which we hope to have out soon.
I am running
sbt compile
for a compiling a program. I am getting the
OutOfMemoryError: Java heap space
Exception. Instead I tried
sbt compile -J-Xms4G -J-Xmx6G
But I don't see any difference in memory usage of the program, like ignoring the command-line options, and I get the same exception (and when crashing it is barely using 0.8GB).
I am programmatically compiling Scala code with this piece of code:
val compiler = new Global(settings, reporter)
val run = new compiler.Run
run compile sourceFiles.map(_.fullPath).toList
The 2.10 RC1 compiler works for like three minutes then crashes, whereas 2.10 infinitely does something (full CPU usage). When I invoke the compiler via SBT (rather than programmatically) it works fine and compiles within less than a minute.
The shortened output looks like this (verbose - and running three minutes between the first line and the error):
[loaded class file C:\Program Files\scala\lib\scala-library.jar(scala/collection/mutable/StringBuilder.class) in 3ms]
Scala 2.10 stable
No further output. 100% CPU usage of 1 Core.
Scala 2.10 RC1
With RC1 I get this error after approximately 3 minutes:
error:
while compiling: Foo.scala
during phase: typer
library version: version 2.10.0-RC1
compiler version: version 2.10.0-RC1
reconstructed args:
Next piece of output (and final output before my application crashes) is an OutOfMemoryError. I'm not sure whether its cause is the code itself or the compile error. Both options appear strange to me, as it compiles on the SBT console and a compiler error should not consume that much memory, should it?
uncaught exception during compilation: java.lang.OutOfMemoryError
[error] (run-main) java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
at scala.reflect.internal.Symbols$Symbol.createRefinementClassSymbol(Symbols.scala:1068)
at scala.reflect.internal.Symbols$Symbol.newRefinementClass(Symbols.scala:406)
at scala.reflect.internal.Types$class.refinedType(Types.scala:3504)
at scala.reflect.internal.SymbolTable.refinedType(SymbolTable.scala:12)
at scala.reflect.internal.Types$Type.narrow(Types.scala:459)
at scala.reflect.internal.Types$class.specializedBy$1(Types.scala:6125)
at scala.reflect.internal.Types$class.specializesSym(Types.scala:6129)
at scala.reflect.internal.SymbolTable.specializesSym(SymbolTable.scala:12)
at scala.reflect.internal.Types$$anonfun$thirdTry$1$2.apply(Types.scala:6021)
at scala.reflect.internal.Types$$anonfun$thirdTry$1$2.apply(Types.scala:6021)
at scala.collection.Iterator$class.forall(Iterator.scala:739)
at scala.collection.AbstractIterator.forall(Iterator.scala:1156)
at scala.collection.IterableLike$class.forall(IterableLike.scala:75)
at scala.reflect.internal.Scopes$Scope.forall(Scopes.scala:44)
at scala.reflect.internal.Types$class.thirdTry$1(Types.scala:6021)
at scala.reflect.internal.Types$class.secondTry$1(Types.scala:5982)
at scala.reflect.internal.Types$class.firstTry$1(Types.scala:5958)
at scala.reflect.internal.Types$class.isSubType2(Types.scala:6101)
at scala.reflect.internal.Types$class.isSubType(Types.scala:5710)
at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:12)
at scala.reflect.internal.Types$class.thirdTry$1(Types.scala:6043)
at scala.reflect.internal.Types$class.secondTry$1(Types.scala:5982)
at scala.reflect.internal.Types$class.firstTry$1(Types.scala:5958)
at scala.reflect.internal.Types$class.isSubType2(Types.scala:6101)
at scala.reflect.internal.Types$class.isSubType(Types.scala:5710)
at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:12)
at scala.reflect.internal.Types$class.scala$reflect$internal$Types$$specializesSym(Types.scala:6142)
at scala.reflect.internal.Types$class.specializedBy$1(Types.scala:6125)
at scala.reflect.internal.Types$class.specializesSym(Types.scala:6129)
at scala.reflect.internal.SymbolTable.specializesSym(SymbolTable.scala:12)
at scala.reflect.internal.Types$$anonfun$thirdTry$1$2.apply(Types.scala:6021)
at scala.reflect.internal.Types$$anonfun$thirdTry$1$2.apply(Types.scala:6021)
[trace] Stack trace suppressed: run 'last compile:run' for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
I stumbled across Why am I getting OutOfMemoryError compilation error in Scala?. I am, however, not sure whether I'm actually simply lacking heap space for the compilation. There is no Maven involved, it's only Scala code and some JARs on the local build path.
I'm looking for the cause of the OutOfMemory error or a tweak to fix the error.
Using jvisualvm.exe (in the JDK) we found out that the compiler was indeed running low on memory. The GC was working too hard freeing memory, so it looked like an infinite loop (to be precise: happened when a symbol table's HashSet was enlarged).
Increasing the heap size to 2GB fixed the issue here.
I have noticed a strange behavior of my scala compiler. It occasionally throws an OutOfMemoryError when compiling a class. Here's the error message:
[info] Compiling 1 Scala source to /Users/gruetter/Workspaces/scala/helloscala/target/scala-2.9.0/test-classes...
java.lang.OutOfMemoryError: PermGen space
Error during sbt execution: java.lang.OutOfMemoryError: PermGen space
It only happens once in a while and the error is usually not thrown on the subsequent compile run. I use Scala 2.9.0 and compile via SBT.
Does anybody have a clue as to what might be the cause for this error? Thanks in advance for your insights.
I use HomeBrew to install sbt on OS X. It supports a SBT_OPTS argument which can be put in ~/.sbtconfig file with export SBT_OPTS=-XX:MaxPermSize=256M.
The cause for OutOfMemoryError: PermGen space is that it doesn't have enough permanent generation space :) If you are using Oracle JVM, you need to add the -XX:MaxPermSize=256M (or some other amount of space) argument to your sbt script. For other JVMs, look at their documentation.
I assumed you're using sbt 0.13.6 or higher. Create .sbtopts file in your sbt project's root with the following content:
-J-Xmx4G
-J-XX:MaxMetaspaceSize=1G
-J-XX:MaxPermSize=1G
-J-XX:+CMSClassUnloadingEnabled
MaxMetaspaceSize is for Java 8 whereas MaxPermSize is for Java 7. They are critical to prevent out of memory errors related either to permgen or metaspace exhaustion. Of course, consider adapting flag values or adding any other flags required.
More details and alternative approaches can be found in this blog post.
I had this issue, played around with it for 10 minutes looking at sites trying to change the memory size.
Turns out i resolved it by,
user-profile$ sbt
Then,
sbt-project-name 0.1> clean
This cleared it up for me.
It looks like a memory leak in SBT for me as in my case the program compiles and runs successfully for about 3-5 times before hitting the exception which is fixed by SBT restart.
The most adequate solution indeed seems to be -XX:MaxPermSize= JVM parameter as Alexey Romanov suggests or to restart SBT periodically if it helps.
But there is another interesting way: try switching to Java 8. AFAIK it doesn't use PermGen any more and is probably immune to this exception this way.
I still hope SBT authors will address this issue in future versions.
I am building with the Jenkins sbt plugin and had the same problems. They were resolved after copying the SBT_OPTS from the sbt file to the Jenkins job config's JVM flags.
Originally using a command like:
java -jar /path/to/sbt-launch.jar test
I got first OutOfMemoryError: PermGen space which I solved using -XX:MaxPermSize, and then OutOfMemoryError: Java heap space, to which -Xmx was the remedy.
So in my case, a command like this worked:
java -XX:MaxPermSize=256M -Xmx2048M -jar /path/to/sbt-launch.jar test
change following code block in sbt.sh file and save its working fine.
get_mem_opts () {
local mem=${1:-1536}
local perm=$(( $mem / 4 ))
(( $perm > 256 )) || perm=1024 //256 to 1024
(( $perm < 1024 )) || perm=2048 // 1024 to 2048
local codecache=$(( $perm / 2 ))
echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m"
}
or
using terminal to export sbt config
export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:PermSize=1024M -XX:MaxPermSize=2048M"
You can also add a .jvmopts file in the root folder of your project, and write inside the file the following:
-Xms1g
-Xmx4g