35

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
Pokuri
  • 2,994
  • 7
  • 28
  • 51
  • 3
    Open `E:\workspace\play\first-app\project\plugins.sbt`. What is the number `X.Y.Z` in the line `addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "X.Y.Z")`? – Salem Jun 26 '15 at 22:02
  • 3
    it's 2.4.1. Now I changed it to 2.3.9 and it's working – Pokuri Jun 27 '15 at 00:51
  • 1
    Could someone create an answer detailing the explicit steps? That is, going into `app/project/plugins.sbt` and replacing the `com.typesafe.play` version with `2.3.9`. The official answer made me think that there was something wrong with my JDK setup, but it seems that changing the (automatically generated) plugins.sbt is the appropriate fix. – cib Aug 11 '15 at 15:25
  • Same error building play 2.4.x on shippable.com build system with openjdk8. Switching to oraclejdk8 build tag fixed the problem. – Adam Lane Nov 28 '15 at 00:13
  • HI Pokuri I too facing the same issue, earlier it was 2.5.9 and I have changed it to 2.3.9, but still facing the same issue. please help me what to do? – Ram Koti May 15 '17 at 05:24

6 Answers6

35

52 = Java 8, 51 = Java 7.. On com.typesafe.config.ConfigException; so you have a too new library.

Joop Eggen
  • 96,344
  • 7
  • 73
  • 121
  • I see that 2.4.x require Java 8 so I have downloaded 2.3.9 from thei link https://playframework.com/download#older-versions. Then how did I got Java 8 compatible files? – Pokuri Jun 26 '15 at 09:27
  • Did you have a prior installation? Check your war for jars falsely taken. Maybe a serialized "confif" object of a too new version (*.ser or whatever) – Joop Eggen Jun 26 '15 at 10:35
  • I have the same issue. I have another project in Play 2.3.9 and I want this one to be 2.4.1. – Pavel Kudinov Jun 30 '15 at 06:57
  • 2
    please can you clarify the solution ? – SaKou Feb 25 '16 at 12:56
  • @SaKou the application running on say Java 6 is using a class compiled for say Java 8. The solution is to search for an older library (if the class is in a library), recompile for an older java if it is your own class, or run the application with a newer java. – Joop Eggen Feb 25 '16 at 19:02
14

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

Ronak Agrawal
  • 428
  • 3
  • 12
2

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"
Rahul Singhai
  • 1,132
  • 13
  • 23
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.

Ram
  • 2,972
  • 10
  • 38
  • 56
soutoner
  • 571
  • 2
  • 14
  • The same problem was for me on Ubuntu 14.04 – lennykey Oct 08 '15 at 19:21
  • 1
    I have the same version of java in the path, but my JAVA_HOME variable was setted for a previous version. Setting the JAVA_HOME to the right version solved the problem. – Decly Nov 12 '15 at 15:11
1

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
Floern
  • 31,495
  • 23
  • 98
  • 115
  • HI, Sunil, I have changed sbt-plugin from 2.5.9 to 2.3.9, but still, I am facing the same issue, please help me, thanks in advance – Ram Koti May 15 '17 at 05:28
0

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.

Matteo Guarnerio
  • 678
  • 1
  • 10
  • 25
Amélie Medem
  • 111
  • 1
  • 5
  • HI, Amelie, i have changed sbt-plugin from 2.5.9 to 2.3.9, but still, i am facing the same issue, please help me – Ram Koti May 15 '17 at 05:27