1
votes

Problem:

IntelliJ is not letting me import a play framework project. It just displays errors when I try to open project using SBT.

Its really simple what I want to do, but I haven't used any of these tools and I'm a bit lost at how to fix this.

I just want to create a Play framework project, and edit it in IntelliJ as shown on multiple tutorials on youtube.

Below I have provided some info about how I have tried to make it work to "help you help me".

I really hope there is some easy solution that I fail to see!

Background info:

I have downloaded and installed IntelliJ 14.1.5 Community Edition and the latest avtivator from Play Framework - Activator 1.3.6 and Play 2.4.3

Note: I also downloaded the latest java jdk, 1.8.0_65 and added both java and activator to path - I'm using Windows 8. I have also downloaded the latest plugin of Scala inside IntelliJ

Then I opened cmd and typed "activator ui" and opened browser at localhost:8888 as instructed in tutorials. I managed to create a "play-java-intro" project. So far, so good.

After this I have tried a few different approaches.

NOTE: I have clicked "Invalidate cache / restart" each time I try something new

First try

I tried to Open project after I had created the project through activator. I selected root directory of the project and selected SDK jdk 1.7 (have tried with 1.8 aswell).

I got the error

Error while importing SBT project: ... 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:129) at xsbt.boot.Launch$.run(Launch.scala:109) at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36) at xsbt.boot.Launch$.launch(Launch.scala:117) at xsbt.boot.Launch$.apply(Launch.scala:19) at xsbt.boot.Boot$.runImpl(Boot.scala:44) at xsbt.boot.Boot$.main(Boot.scala:20) 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.

Inside the log file:

[info] Loading project definition from C:\play-java-intro\project
[info] Set current project to play-java-intro (in build file:/C:/play-java-intro/) 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:129) at xsbt.boot.Launch$.run(Launch.scala:109) at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36) at xsbt.boot.Launch$.launch(Launch.scala:117) at xsbt.boot.Launch$.apply(Launch.scala:19) at xsbt.boot.Boot$.runImpl(Boot.scala:44) at xsbt.boot.Boot$.main(Boot.scala:20) 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.

I have tried to search what this means, but the answers I find on google wont apply to my problem.

I have tried to select and deselect all of the options within SBT - Use auto-import, Download sources and docs etc.. But still the same error message.

Second try

Similar to first try, but I clicked "Create IntelliJ project" inside activator at localhost:8888 and then tried to import the project the same method as First try.

Third try

Open project and select the root directory, and I managed to import the project somewhat, but its moved project files to "project backup" and I got lots of warnings saying its based on a outdated version. Didn't quite understand this.

Fourth try

Create project from existing sources after creating the project at activator, and I got the project imported without warnings.

But when I open Application.java (or any other file for that matter), everything inside that file gets red underlined with a error saying similar to "Cannot resolve symbol 'Result'" and I cant compile anything.

I have tried to open modules and click + and add Scala as a module, but it doesn't seem to make any difference.


I really hope there is someone out there that can help me as this should be a fairly easy thing to install IntelliJ + Play framework.

2
Did not you forget to enable scala plugin ? You can download it but leave it disabled, so just check. This is a good guide with screens: jetbrains.com/idea/help/…Andriy Kuba

2 Answers

7
votes

The issue is that even if IntelliJ is set to use JDK8, the SBT process is using JDK7 (you can confirm that looking at it with a tool like JVisualVM). Not sure what their logic is to pick up SBT's JVM, but you can force it when you import the projet:

This solved it for me with this version of Idea:

3
votes

From the documentation: https://www.playframework.com/documentation/2.4.x/Highlights24

Play 2.4 now requires JDK 8

So you definitely must use only JDK 8.

Unsupported major.minor version 52.0

Means that you try to open project that was compiled with JDK 8 but your settings in IDE is JDK 7 (or less)

My proposition - check twice if you really use JDK8 in the intelliJ