Mac OS X Activator New Play Framework Error

1.5k views Asked by At

I'm running the most recent Yosemite 10.10.3 with the latest activator from Typesafe 1.3.4 and I tried creating a new Scala Project template 6 and I can no longer run the template without this error.

[info] Loading project definition from /Users/Master/x/x/project
java.lang.UnsupportedClassVersionError: play/runsupport/classloader/ApplicationClassLoaderProvider : 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 play.sbt.run.PlayRun$.<init>(PlayRun.scala:35)
    at play.sbt.run.PlayRun$.<clinit>(PlayRun.scala)
    at play.sbt.PlaySettings$.defaultSettings$lzycompute(PlaySettings.scala:70)
    at play.sbt.PlaySettings$.defaultSettings(PlaySettings.scala:47)
    at play.sbt.Play$.projectSettings(Play.scala:26)
    at sbt.Load$$anonfun$autoPluginSettings$1$1.apply(Load.scala:666)
    at sbt.Load$$anonfun$autoPluginSettings$1$1.apply(Load.scala:666)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
    at sbt.Load$.autoPluginSettings$1(Load.scala:666)
    at sbt.Load$.sbt$Load$$expandSettings$1(Load.scala:681)
    at sbt.Load$$anonfun$sbt$Load$$expandSettings$1$2.apply(Load.scala:682)
    at sbt.Load$$anonfun$sbt$Load$$expandSettings$1$2.apply(Load.scala:682)
    at scala.collection.IndexedSeqOptimized$class.foldl(IndexedSeqOptimized.scala:51)
    at scala.collection.IndexedSeqOptimized$class.foldLeft(IndexedSeqOptimized.scala:60)
    at scala.collection.mutable.WrappedArray.foldLeft(WrappedArray.scala:34)
    at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:138)
    at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:105)
    at sbt.Load$.sbt$Load$$expandSettings$1(Load.scala:682)
    at sbt.Load$.resolveProject(Load.scala:684)
    at sbt.Load$.finalizeProject$1(Load.scala:549)
    at sbt.Load$.loadTransitive(Load.scala:577)
    at sbt.Load$.loadProjects$1(Load.scala:442)
    at sbt.Load$.loadUnit(Load.scala:446)
    at sbt.Load$$anonfun$18$$anonfun$apply$11.apply(Load.scala:281)
    at sbt.Load$$anonfun$18$$anonfun$apply$11.apply(Load.scala:281)
    at sbt.BuildLoader$$anonfun$componentLoader$1$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(BuildLoader.scala:91)
    at sbt.BuildLoader$$anonfun$componentLoader$1$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(BuildLoader.scala:90)
    at sbt.BuildLoader.apply(BuildLoader.scala:140)
    at sbt.Load$.loadAll(Load.scala:334)
    at sbt.Load$.loadURI(Load.scala:289)
    at sbt.Load$.load(Load.scala:285)
    at sbt.Load$.load(Load.scala:276)
    at sbt.Load$.apply(Load.scala:130)
    at sbt.Load$.defaultLoad(Load.scala:36)
    at sbt.BuiltinCommands$.doLoadProject(Main.scala:481)
    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: play/runsupport/classloader/ApplicationClassLoaderProvider : Unsupported major.minor version 52.0
4

There are 4 answers

0
nkadwa On BEST ANSWER

The latest Play framework starting at version 2.4.0 requires Java 1.8. Upgrade to resolve.

PlayFramework ChangeLog

1
Kai Sternad On

This is the relevant part of your stack trace:

java.lang.UnsupportedClassVersionError:      
play/runsupport/classloader/ApplicationClassLoaderProvider : Unsupported  
major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at

It means that you have Java 7 installed, but it is not supported by the template. Try using the template with Java 8 instead.

0
MockerTim On

As @nkadwa already mentioned the latest Play framework starting at version 2.4.0 requires Java 1.8.

It's worth to mention, that in the Windows OS, the activator command uses JAVA_HOME environment variable, if it is set, to find Java instance to work with.

So, even if you've installed Java 8, the JAVA_HOME env variable can point to the old version of JDK. This maybe one of the reasons for that mistake to emerge.

Set JAVA_HOME variable to point onto the new version of JDK, or remove JAVA_HOME variable (if you just want to use JRE) to resolve this.

0
Philips On

If you are using playframework 2.4.2, ensure that you have set your development machine to use java 1.8.0+

This is how you change set your machine to use java 1.8 on ubuntu

  1. Set the java version sudo update-alternatives --config java

There are 5 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

  • 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 20004 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 20002 manual mode 3 /usr/lib/jvm/java-8-oracle/bin/java 20000 manual mode 4 /usr/lib/jvm/java-8-oracle/jre/bin/java 20004 manual mode 5 /usr/lib/jvm/jre1.7.0_45/bin/java 1 manual mode Press enter to keep the current choice[*], or type selection number:

2.Set the javac version sudo update-alternatives --config javac

There are 5 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

  • 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 20004 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 20002 manual mode 3 /usr/lib/jvm/java-8-oracle/bin/java 20000 manual mode 4 /usr/lib/jvm/java-8-oracle/jre/bin/java 20004 manual mode 5 /usr/lib/jvm/jre1.7.0_45/bin/java 1 manual mode Press enter to keep the current choice[*], or type selection number:

    1. set the JAVA_HOME at to the java 1.8 source( /usr/lib/jvm/java-8-oracle/jre/bin/java )

~/.bashrc However for Java, I followed instructions at https://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7

and it was sufficient for me.

you can also define multiple java_home's and have only one of them active (rest commented).

suppose in your bashrc file, you have

export JAVA_HOME=......jdk1.7

export JAVA_HOME=......jdk1.8

notice 1.8 is commented. Once you do

source ~/.bashrc

jdk1.7 will be in path.

you can switch them fairly easily this way. There are other more permanent solutions too. The link I posted has that info.