How to debug a Scala SBT project in IntelliJ 13?
I have never tried using any sort of debugger with Scala and never tried debugging anything in IntelliJ Idea (while I have been using Idea to write Scala code). Now, as the recent IntelliJ Idea 13 has gotten built-in SBT support I have tried to use this feature (instead of the old sbt-idea SBT plug-in way) to import an SBT project and this seems to work. But what I can't figure out is how to run and debug the program in this case. Of course I can use the conventional SBT command line way to build and run but isn't Idea supposed to have native ways for this now? The first window I've illustrated below that pops-up when I click Run-Debug or Run-Run suggests it is, as well as the second (the Project Structure window) which is called.
(note that the Run button is disabled (grayed) and never goes enabled whatever I do)
Why does it complain about the SBT::scala-compiler-bundle:2.11.0 library not used by the way? How am I intended to use it? Isn't it the compiler/SBT/IDE who needs it?
Also, when I click Build - Make Project an Abnormal build process termination exception (java.lang.reflect.InvocationTargetException) emerges:
Error:Abnormal build process termination: Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.jetbrains.jps.cmdline.Launcher.main(Launcher.java:54) Caused by: java.lang.IllegalStateException: failed to create a child event loop at io.netty.util.concurrent.MultithreadEventExecutorGroup.(MultithreadEventExecutorGroup.java:73) at io.netty.channel.MultithreadEventLoopGroup.(MultithreadEventLoopGroup.java:51) at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:72) at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:58) at org.jetbrains.jps.cmdline.BuildMain.main(BuildMain.java:77) ... 5 more Caused by: io.netty.channel.ChannelException: failed to open a new selector at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:128)
What am I doing wrong?
PS: I am using the latest stable Java, Scala, SBT, and Idea releases to this date.
If someone experiences similar things like eg:
You can either do as suggested in a previous comment (maybe this helps in your case!) or you do what helped me..
What I did to create my project:
I created my basic project (using play 2.3 scala template) with the activator command. After that I imported the project (IDEA 13.1.4). Building the project from from the command line worked perfeclty while the project in my IDE went crazy.. (like I described above)
Solution:
Go to your "project structure" and remove one of the three modules IntelliJ configured on project import. It configures a "root" module containing all the necessary dependencies, a "root-build" module and a module named after your project. The solution is to remove the module which is named after your project and add the "scala-compiler-bundle" to your root module. After that my project worked totally fine inside IntelliJ.
I hope this will help someone in the future.
链接地址: http://www.djcxy.com/p/20014.html