I am running a web application with Scala version 2.9.0 and Scalatra version 2.1.0-SNAPSHOT. I build the application with Java 1.6. It runs fine when I run it with Java 1.7 but fails when ran with Java 1.8 with this error. What can be the issue?
It is important for me to run with java 1.8 is because I have some third party jars used in my application which are complied with java 1.8. I have other scala applications with I have built with java 1.6 and run fine with java 1.8 but I am only facing this issue with applications using scalatra.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.fusesource.scalate.TemplateException
org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:834)
org.fusesource.scalate.TemplateEngine.compileAndLoadEntry(TemplateEngine.scala:691)
org.fusesource.scalate.TemplateEngine.liftedTree1$1(TemplateEngine.scala:411)
org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:405)
org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:475)
org.scalatra.scalate.ScalateSupport$class.renderScalateErrorPage(ScalateSupport.scala:140)
org.scalatra.scalate.ScalateSupport$class.handle(ScalateSupport.scala:131)
root cause
java.lang.NullPointerException
scala.tools.nsc.Global$Run.compileLate(Global.scala:1043)
scala.tools.nsc.symtab.SymbolLoaders$SourcefileLoader.doComplete(SymbolLoaders.scala:303)
scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:111)
scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:85)
scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:732)
The release notes for Scala 2.9 list it's dependencies: "It requires the Java runtime version 1.6 or 1.7." Scala 2.11.1 announced support for Java 8 but called that "experimental." The experimental adjective was dropped from the release notes in Scala 2.11.2, but I've had problems with Java 8 in projects using later versions of Scala (probably 2.11.7).
Related
while building through Intellij Idea, I got the following message:
Error:scalac: 'jvm-1.10' is not a valid choice for '-target'
Error:scalac: bad option: '-target:jvm-1.10'
later, after a Java upgrade
Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM:
1.8 Build, Execution, Deployment -> Complier -> Scala Complier -> Scala Compile Server -> JDK: 1.8
in build.gradle
compileScala.targetCompatibility = 1.8
ScalaCompileOptions.metaClass.useAnt = false
Nothing helps!
upd:
this helps: in build.gradle
tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = false
}
not needed:
compileScala.targetCompatibility = 1.8
ScalaCompileOptions.metaClass.useAnt = false
"Error:scalac: 'jvm-1.10' is not a valid choice for '-target' Error:scalac: bad option: '-target:jvm-1.10'"
In the JDK compatibility notes as mentioned below, it also indicates
that the Java 10 is not fully supporting Scala 2.12.6 JDK 9 & 10
compatibility notes
As you were saying you build this through IntelliJ IDEA, I suspect
you haven't configure your java version (Java 10) or scala version
(2.12.6) inside running configuration project settings.
And also please try out building/compile your application through
commandline in order to check whether you are getting the same error
with that (Otherwise this is just bad configuration in IDEA tht you
need to change)
JDK 9 & 10 compatibility notes (Mentioned in Scala Docs)
JDK 9 & 10 compatibility notes
As of Scala 2.12.6 and 2.11.12, JDK 9 & 10 support is incomplete. Notably, scalac will not enforce the restrictions of the Java Platform Module System, which means that code that typechecks may incur linkage errors at runtime.
JDK 9 & 10 support requires minimum sbt version 1.1.0, or 0.13.17 in the 0.13.x series.
For more information on JDK 9 & 10 compatibility, watch the “Support JDK 9” issue on GitHub.
The same issue can happen with mixed multi-module gradle projects that use java 11 and scala 2.12.10.
In that case, it may help to reconfigure IntelliJ (2019.2) via
Settings > Build, Execution, Deployment > Scala Compiler
by removing the targets defined in Additional compiler options for the affected scala modules.
I stumbled over this issue when having the same problem with Java 11. The reconfiguration comment of Roland Ewald solved the problem. It is important to mention, that this reconfiguration has to be made for all modules of the project (at least for me this was necessary) as well as that IntelliJ sometimes hides parts of the Additional compiler options, so be sure to click on expand even if they seem empty or correct.
I have created new Play + Scala project using latest typesafe activator and when trying to import in IntelliJ IDE I was getting below error,
info] Loading project definition from E:\Personal\Scala Workspace\DeployZip\project
E:\Personal\Scala Workspace\DeployZip\build.sbt:18: error: not found: value routesGenerator
routesGenerator := InjectedRoutesGenerator
^
[error] Type error in expression
Consult IDE log for more details (Help | Show Log)
What are the possible reasons for this error?
I have installed jdk 1.8 and now I am able to create project successfully without any error.
But when I tried to run play application using
activator run
I was getting below error now,
java.lang.UnsupportedClassVersionError: org/webjars/WebJarExtractor$Cache : Unsupported major.minor version 51.0
According to this article, I think Unsupported major.minor version 51.0 means that your play application were compiled with Java 1.7 (version 51), but you have Java 1.8 (version 52) installed instead, so you got this error. I'd suggest that you refer to this article for how you could switch between different Java versions.
I was having the error that said Unsupported major.minor version 52.0, and after I installed the latest one (Java 1.8) it was solved.
Hope this helps.
Here is what I've done to solve the issue. Even if you install the java 1.8 it is not sufficient. You have to update the 'path' and 'JAVA_HOME'.
After you install, try to set the jdk1.8 path in the PATH of the environment variables. Also make sure that if you have other versions of the java in the PATH then put the jdk 1.8 path prior to the previous version of java. Or just in case put it in the very beginning of the paths.
I had this same issue. Everything worked after I upgraded Intellij to the latest version (maybe my outdated version used JDK1.7, while activator used 1.8?).
I have a grails application with 2.4.1 grails version and used 2.3 groovy compiler.
I am getting following error when I try to run
java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.DefaultGroovyMethods.count(Ljava/lang/Iterable;Lgroovy/lang/Closure;)Ljava/lang/Number;
at org.codehaus.groovy.grails.compiler.web.ControllerActionTransformer.processMethods(ControllerActionTransformer.java:234)
at org.codehaus.groovy.grails.compiler.web.ControllerActionTransformer.performInjectionOnAnnotatedClass(ControllerActionTransformer.java:204)
at org.codehaus.groovy.grails.compiler.web.ControllerActionTransformer.performInjection(ControllerActionTransformer.java:196)
at org.codehaus.groovy.grails.compiler.injection.GrailsAwareInjectionOperation.call(GrailsAwareInjectionOperation.java:154)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1213)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:645)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:623)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:600)
at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:185)
at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.analyseCode(GroovyCompilationUnitDeclaration.java:2213)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:834)
at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
at java.lang.Thread.run(Thread.java:701)
Grails 2.4.1 shipped with Groovy 2.3.3 and that is the only version of Groovy supported with that version of Grails. Normally you don't do anything to associate a version of Groovy with a version of Grails. Grails uses the version that is shipped with it.
Make sure that your GRAILS_HOME points to Grails 2.4.1 and that GRAILS_HOME/bin is on your PATH. If you have a different version of Grails on your PATH than the one that GRAILS_HOME points to, that can sometimes cause peculiar behavior.
I hope that helps.
I am try to play with Kestrel 2.4.1 (http://robey.github.io/kestrel/). Unfortunately, it does not launch. I get the following exception when I run the devel.sh script. IOther scripts produce similar exception.
Starting kestrel in development mode...
May 17, 2014 2:26:06 PM java.util.logging.LogManager$RootLogger log
FATAL: Error in config file: %s
java.lang.UnsupportedOperationException: Position.line
at scala.tools.nsc.util.Position$class.line(Position.scala:173)
at scala.tools.nsc.util.NoPosition$.line(Position.scala:196)
at com.twitter.util.Eval$StringCompiler$$anon$1.display(Eval.scala:444)
at scala.tools.nsc.reporters.AbstractReporter.info0(AbstractReporter.scala:45)
Any help would be appreciated. I am using Java 8.
Scala support for Java 8 is experimental even in 2.11.0, and the github version has the last version of Scala being used as 2.9.2
From: Kestrel Build File
scalaVersion := "2.9.2",
From: SCALA 2.11.0 IS NOW AVAILABLE!
The Scala 2.11.x series targets Java 6, with (evolving) experimental support for Java 8. In 2.11.0, Java 8 support is mostly limited to reading Java 8 bytecode and parsing Java 8 source. Stay tuned for more complete (experimental) Java 8 support.
I would not expect this to work on Java 8 without having to fix compile issues for 2.10 and 2.11 and then Scala would need better support for Java 8.
Actually it's Logger can not init correctly.
Make sure queuePath and filename of development.scala are available.
I try to deploy a simple "Hello Word" in my local server GlasshFish 3, but at the deploy the console print this message
[#|2013-01-15T15:00:02.458+0100|SEVERE|glassfish3.1.2|
javax.enterprise.system.tools.admin.org.Exception while deploying the app
[HelloWorldEJB] :UnsupportedClassVersionError: Class ejb_other.PlaceAuctionItemBean
as unsupported major or minor version numbers, which are greater than those found
in the Java Runtime Environment version 1.6.0_27|#]
My JAVA_HOME has java version 1.6.0_27 (it refers to _C:\Program Files\Java\jdk1.6.0_27_), my Eclipse (indigo) project refers to java 1.6.0_27.
I think (i don't know how to verify) that GlasshFish refers to JAVA_HOME.
In my PC (Windows 7) I found 2 directory having java.exe:
C:\Windows\SysWOW64>java -version -->>java version "1.6.0_29"
C:\Windows\System32>java -version -->>java version "1.6.0_27"
I found more discussions about this exception (f.e. this or this ), but I need of something more specific for Eclipse/Glasshfish, because I can't to solve. I see that the JVM is the same for compilation and execution.
Post Scriptim
I add the screenshot about the places where I declare JVM: it's always 1.6.
one:
two:
three:
Where can I see that I compile with java 7 or it runs with another JVM?
ejb_other.PlaceAuctionItemBean was obviously compiled for Java 7 which won't work if you run it in a Java 6 JVM.
Found solution
There's another place where setting the compiler's options:
how do I get eclipse to use a different compiler version for Java?