Troubles launching Kestrel - scala

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.

Related

Scala not builds on Java 10

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.

Scalatra throwing null pointer exception with java 8

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).

Missing dependencies in Apache Crunch Scala build

I'm trying to build the Apache Crunch source code on my CentOS 7 machine, but am getting the following error in the crunch-spark project when I execute mvn package:
[ERROR] /home/bwatson/programming/git/crunch/crunch-spark/src/it/scala/org/apache/crunch/scrunch/spark/PageRankClassTest.scala:71: error: bad symbolic reference. A signature in PTypeH.class refers to term protobuf
[ERROR] in package com.google which is not available.
[ERROR] It may be completely missing from the current classpath, or the version on
[ERROR] the classpath might be incompatible with the version used when compiling PTypeH.class.
[ERROR] .map(line => { val urls = line.split("\\t"); (urls(0), urls(1)) })
[ERROR] ^
Other SO questions about similar errors (here and here) seem to involve PATH or version issues. I've been messing around but can't seem to resolve them. For completeness:
[bwatson#ben-pc crunch]$ scala -version
Scala code runner version 2.11.5 -- Copyright 2002-2013, LAMP/EPFL
[bwatson#ben-pc crunch]$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
[bwatson#ben-pc crunch]$ mvn -version
Apache Maven 3.0.5 (Red Hat 3.0.5-16)
Maven home: /usr/share/maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_31/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-123.20.1.el7.x86_64", arch: "amd64", family: "unix"
Any advice? I'm not really sure where Scala is looking for its dependencies, but I'd have thought that Maven would take care of it.
Unfortunately Different versions of Scala are binary incompatible. Currently by default Apache Spark uses Scala 2.10.4, not Scala 2.11. Apache Scrunch is dependent on Spark. Maven does not know anything about this so it can't help. It is necessary to make some modifications to Scrunch to get it to compile for Scala 2.11 / JDK 1.8. I am working on this at the moment, but I don't have a solution yet. However I get the error message you report if I compile Scala 2.10.4 with JDK 1.8, not Scala 2.11, so I don't think it is doing quite what you intend. The error seems be coming from the Protobuf compiler or jar but I don't know why that is.
When I solve it myself, I will report back!
It turns out the official documentation for Crunch was missing a Maven parameter. The issue was solved by building using:
mvn package -Dcrunch.platform=2

UnsupportedClassVersionError deploying EJB "HelloWord" in Glasshfish 3

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?

compiling scala program on jvm

What version of the scala library jar will support java 1.5 and 1.6
And also how to compile in java?
Scala's jar files are compiled with JVM 1.5, as can be seen by looking into the META-INF/MANIFEST.MF file. Here is 2.8.1: Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.).
The Scala compiler generates output that is compatible with jvm-5 (see scalac -target). Also, it has some magic to enable use with jdk 1.6, in which String has added a method that Scala defines on WrappedString.
Scala is compiled with the scalac compiler and not javac. To run the Scala code you need Java runtime/sdk version 1.5 or later and the scala library jar.
Version 2.7.7 and 2.8.1 are the common versions used today. If you start a new project now you should aim for 2.8.1 or 2.9 (which is going to be available soon-ish). Download site is here
See the FAQ