Using phoenix to save a dataframe on Hbase - java

As the title says, I want to save my DataFrame with phoenix.
I have a spark code in scala that I run on intellij IDEA.
It is quite simple :
import org.apache.spark.sql.SparkSession
import org.apache.phoenix.spark._
object MainTest extends App {
val sparkSession = SparkSession.builder()
.config("spark.sql.warehouse.dir", "file:///c:/tmp/spark-warehouse")
.master("local[*]")
.appName("spark-to-hbase")
.getOrCreate()
val sc = sparkSession.sparkContext
val sqlC = sparkSession.sqlContext
import sqlC.implicits._
val myRdd = sc.parallelize(List(("a",1), ("b", 2)))
myRdd.collect.foreach(println)
val myDf = myRdd.toDF("column1", "column2")
myDf.show()
myDf.saveToPhoenix("MY_TABLE", zkUrl = Some("localhost:16000"))
}
I also have a HBase database runing on the same pc on the port 16000.
The problem is that the line
myDf.saveToPhoenix("MY_TABLE", zkUrl = Some("localhost:16000"))
throw this exception :
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/hadoop/hbase/types/DataType at
java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(ClassLoader.java:763) at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at
java.net.URLClassLoader.access$100(URLClassLoader.java:73) at
java.net.URLClassLoader$1.run(URLClassLoader.java:368) at
java.net.URLClassLoader$1.run(URLClassLoader.java:362) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:361) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
org.apache.phoenix.spark.DataFrameFunctions$$anonfun$getFieldArray$2.apply(DataFrameFunctions.scala:72)
at
org.apache.phoenix.spark.DataFrameFunctions$$anonfun$getFieldArray$2.apply(DataFrameFunctions.scala:72)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at
scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at
scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
at
scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:186)
at
org.apache.phoenix.spark.DataFrameFunctions.getFieldArray(DataFrameFunctions.scala:72)
at
org.apache.phoenix.spark.DataFrameFunctions.saveToPhoenix(DataFrameFunctions.scala:35)
at MainTest$.delayedEndpoint$MainTest$1(MainTest.scala:23) at
MainTest$delayedInit$body.apply(MainTest.scala:8) at
scala.Function0$class.apply$mcV$sp(Function0.scala:34) at
scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76) at
scala.App$$anonfun$main$1.apply(App.scala:76) at
scala.collection.immutable.List.foreach(List.scala:381) at
scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76) at
MainTest$.main(MainTest.scala:8) at MainTest.main(MainTest.scala)
Caused by: java.lang.ClassNotFoundException:
org.apache.hadoop.hbase.types.DataType at
java.net.URLClassLoader.findClass(URLClassLoader.java:381) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 33 more
From what I understand, it seems that java can't find some class.
What can I do ?
My SBT :
name := "spark-to-hbase"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.3.0",
"org.apache.phoenix" % "phoenix-core" % "4.11.0-HBase-1.3",
"org.apache.spark" % "spark-core_2.11" % "2.1.1",
"org.apache.spark" % "spark-sql_2.11" % "2.1.1",
"org.apache.phoenix" % "phoenix-spark" % "4.11.0-HBase-1.3"
)

Method saveToPhoenix takes RDDs. For dataframes, use save (see this doc for more details):
myDf.save("org.apache.phoenix.spark", SaveMode.Overwrite,
Map("MY_TABLE" -> "OUTPUT_TABLE", "zkUrl" -> "localhost:16000"))

I found a solution to my problem.
As the exception says, my compiler isn't able to find the class HBaseConfiguration.
HBaseConfiguration is used inside org.apache.hadoop.hbase library and so is needed to compile.
I noticed that the HBaseConfiguration class wasn't present in the org.apache.hadoop library as I thought.
For the hbase 1.3.1 version installed on my PC computer, I managed to find this class in the hbase-common-1.3.1 jar located in my HBASE_HOME/lib folder.
Then I include this dependency in my built.SBT :
"org.apache.hbase" % "hbase-common" % "1.3.1"
And the Exception was gone.

Related

Docker starts the springboot project and reports java version error

I use the following dockerfile to generate a image call userservice
FROM java:8-alpine
COPY ./userservice.jar /tmp/userservice.jar
ENTRYPOINT java -jar /tmp/userservice.jar
then I use the following command to run container
docker run --name userservice_container userservice
But the terminal prompts that the java version does not match,as follows:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/imortal/UserApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
So I went to check the compiled bytecode version, it is indeed 52, I don’t know why this error is still reported
javap -verbose .\UserApplication.class
public class com.imortal.UserApplication
minor version: 0
major version: 52
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #2 //
com/imortal/UserApplication
super_class: #4 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 2
Use a docker image that has a compatible jdk version, so that it doesn't create any conflict with all the microservices that you are having. This issue probably is occuring because one of your microservices is build on some other jdk version.

Compiling and running JUnit test suite

I've made a JUnit test suite but I'm failing to build and run it from the command line as opposed to just letting IntelliJ perform its magic. I've downloaded junit-4.12.jar and hamcrest-core-1.3.jar. I'm ideally looking for a "portable" solution, i.e. one where all the necessary parameters are in the command rather than in a path variable in a bash file somewhere.
I believe I can compile it fine with: javac -cp /path/to/junit-4.12.jar:. TestSuite.java. This produces a TestSuite.class file with no errors.
But I've tried every command I can find to run it and I always get errors. For example: java -cp /path/to/junit-4.12.jar:/path/to/hamcrest-core-1.3.jar:. org.junit.runner.JUnitCore TestSuite gives:
JUnit version 4.12
Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.junit.runner.Computer.getSuite(Computer.java:28)
at org.junit.runner.Request.classes(Request.java:75)
at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:118)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
Any ideas what's going wrong?
I think if you surround your classpath with double quotes and use semi-colon instead of colon for the delimiter, it should work:
java -cp "/path/to/junit-4.12.jar;/path/to/hamcrest-core-1.3.jar;." org.junit.runner.JUnitCore TestSuite
If you still get the same error, then I think you just have a typo in your hamcrest path.

Scala Spark MLLib NoClassDefFoundError

I am learning ALS in Spark mllib
bu when i try to create Rating to passing to ALS.train I got this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/mllib/recommendation/Rating
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:126)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.mllib.recommendation.Rating
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 5 more
Process finished with exit code 1
I use
sbt 0.13.15,
Scala 2.10.4,
spark-core 2.10,
spark-mllib 2.10,
tried on both java 7 and 8
Did I do something wrong?
I found the solution for my case
the thing is i try to run this spark with IntelliJ IDE and I found that in my Build.sbt i have something like this to use dependencies
libraryDependencies ++= Seq( "org.apache.spark" % "spark-core_2.10" % "2.1.0" , "org.apache.spark" % "spark-mllib_2.10" % "2.1.0" % "provided" )
the problem is at "provided" i should change this to "compile" when i try to run with IntelliJ otherwise i'll see error like that
Yep, just remove the provided will solve the problem
libraryDependencies ++= Seq( "org.apache.spark" % "spark-core_2.10" % "2.1.0" ,
"org.apache.spark" % "spark-mllib_2.10" % "2.1.0" )

java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0 in play framework project [duplicate]

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 5 years ago.
Hi Everyone i was facing the below error
[error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
i was using play framework of version 2.5.9.
and java of version 1.7
please find my build and plugins file :
build.sbt
name := """getbike2"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
"org.mockito" % "mockito-core" % "2.2.22",
"com.google.code.gson" % "gson" % "1.7.1",
"commons-io" % "commons-io" % "2.4",
"org.apache.directory.studio" % "org.apache.commons.io" % "2.4",
"org.apache.poi" % "poi" %"3.9",
"org.apache.poi" % "poi-ooxml" % "3.9"
)
jacoco.settings
parallelExecution in jacoco.Config := false
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-q", "-a")
plugins.sbt:
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.9")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")
// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.2.0")
Terminal log:
vave#vave-Lenovo-G500:~/Desktop/getbike/getbike$ activator
[info] Loading project definition from /home/vave/Desktop/getbike/getbike/project
[info] Set current project to getbike2 (in build file:/home/vave/Desktop/getbike/getbike/)
java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:559)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:559)
at scala.Option.fold(Option.scala:157)
at com.typesafe.sbt.web.SbtWeb$.com$typesafe$sbt$web$SbtWeb$$load(SbtWeb.scala:573)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at sbt.Project$.setProject(Project.scala:319)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:503)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:484)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:484)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:96)
at sbt.MainLoop$.run(MainLoop.scala:89)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
at sbt.MainLoop$.runLogged(MainLoop.scala:22)
at sbt.StandardMain$.runManaged(Main.scala:54)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
So please help me how to fix this issue.
Thanks in advance
The Play framework requires Java 8 from version 2.4.0 and higher. You should update your Java to version 8 if you want to keep using Play 2.5.9.
https://www.playframework.com/changelog
Play 2.4.0 “Damiya”
Released 26 May 2015
Dependency injection out of the box.
Testing is easier thanks to better support for mocking.
It is now straightforward to embed Play in your application.
You can now aggregate reverse routers from multiple projects.
More Java 8 integration —- Java 8 is now required.
Choice of standard project layout.
Many new anorm features. Anorm is now its own project!
Upgraded to Ebean 4. Ebean is (also) its own project!
HikariCP is the default connection pool
WS supports Server Name Identification (SNI).

UnsupportedClassVersionError on running play application with JDK 1.7

Just now started learning Play framework for my project requirement and my project only build on JDK 1.7 so I have downloaded Play 2.3.9 version and created a sample project by typing activator new. Then moved into the sample project directory and executed activator run. Then I see JDk incompatible exceptions. Where I have to make the changes to handle this?
log:
[info] Loading project definition from E:\workspace\play\first-app\project
[info] Set current project to first-app (in build file:/E:/workspace/play/first-app/)
java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:535)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:535)
at scala.Option.fold(Option.scala:157)
at com.typesafe.sbt.web.SbtWeb$.com$typesafe$sbt$web$SbtWeb$$load(SbtWeb.scala:549)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at sbt.Project$.setProject(Project.scala:319)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:484)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$.process(Command.scala:92)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
52 = Java 8, 51 = Java 7.. On com.typesafe.config.ConfigException; so you have a too new library.
Description :
Java SE 8 = 52
Java SE 7 = 51
Java SE 6.0 = 50
Java 8 has major version 52, which means if we run javac command from Java 8 installation, it will by default generate a class with major version 52. However, if we run class file in JRE 7, we will get "Unsupported major.minor version 52.0".
Solution :
There was a mis configuration in %JAVA_HOME%
java -version java version "1.8.0_45"
javac -version javac 1.8.0_45
#echo %JAVA_HOME% C:\Program Files\Java\jdk1.7.0_75
To set the path temporary
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
#echo %JAVA_HOME% C:\Program Files\Java\jdk1.8.0_45
ConfigException occurs because from version 1.3.0, com.typesafe.config library is only compatible with JDK8; see README. You need to downgrade the library version. Use
"com.typesafe" % "config" % "1.2.1"
Although it seemed I was using the same version for java and javac:
java -version java version "1.8.0_51"
javac -version javac 1.8.0_51
My problem was (Linux Mint 17.1) that I had installed oracle-java7 and oracle-java8 so somewhere there must be a misconfiguration.
I uninstalled oracle-java7 and everything worked fine to me.
Faced similar issue, resolved by changing version
//addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.9")
With above changes below exception got resolved (note: system has java 7)
Exception got with higher version:
[info] Set current project to helloworld (in build file:/Users/suniltonger/Projects/play/helloworld/helloworld/)
java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:559)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:559)
at scala.Option.fold(Option.scala:157)
at com.typesafe.sbt.web.SbtWeb$.com$typesafe$sbt$web$SbtWeb$$load(SbtWeb.scala:573)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at sbt.Project$.setProject(Project.scala:319)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:503)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:484)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:484)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:96)
at sbt.MainLoop$.run(MainLoop.scala:89)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
at sbt.MainLoop$.runLogged(MainLoop.scala:22)
at sbt.StandardMain$.runManaged(Main.scala:54)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
[error] Use 'last' for the full log.
[debug] > load-failed
Indeed what #cib is saying solves my problem.
Just modify the file plugins.sbt in my projet directory.
Change the line :
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
to:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.9")
and you'll not get any errors doing activator run again.

Categories