Scalac internal error: ClassNotFoundException

I'm getting the following issue trying to compile my project:

Information:Compilation completed with 11 errors and 0 warnings
Information:11 errors
Information:0 warnings
Error:Scalac internal error: class java.lang.ClassNotFoundException [$, Method),, java.lang.ClassLoader.loadClass(, sun.misc.Launcher$AppClassLoader.loadClass(, java.lang.ClassLoader.loadClass(, java.lang.ClassLoader.loadClassInternal(, java.lang.Class.forName0(Native Method), java.lang.Class.forName(, org.jetbrains.plugins.scala.compiler.rt.ScalacRunner.main(]$ Method)
Error:java.lang.Class.forName0(Native Method)

I'm running build UC 93.13 with Scala 0.3.385 on JDK 1.6.0_17 (Windows 7). The project is managed by maven.

I've had this problem with a number of different versions of IntelliJ, the Scala plugin and on OSX and Linux.

And worst of all, it just "starts" happening, meaning that the plugin works well and then after a day or so, it just stops compiling.

I've gone through a number of forum posts that suggest things like making sure that all modules have the Scala facet turned, the same Scala version, specifying the compiler and SDK in the facet etc, to no avail.

Does anybody know the most effective way to debug this? Is it a case of building the plugin myself and stepping through it? Or should I post a project that will recreate this?


Comment actions Permalink

A while ago I added some logging of the raw compiler output to help track this down.

Instructions here:;a=commit;h=563ff3ffb6e49ae63c937fc95d447515fcb12209

The compiler output will be in the normal idea.log file.

Check that scala-compiler.jar and scala-library.jar are in the classpath every module with the Scala facet attached. The Maven import should handle this, if you have them as dependencies in the POM(s).

Remember to disable the logging when you are done as it slows things down.


Comment actions Permalink

It's important to know, what Scala compiler you use, with what libraries.
If you attached old libriaries and use new compiler or vise versa then it's normal situation. Please check your facet configuration and your attached libraries.

Best regards,
Alexander Podkhalyuzin.

Comment actions Permalink

Thanks for the response, it seems to work consistently now.

I've waited a day to see if the problem comes back, but, as yet, it hasn't. The reason why I waited is because I've been using this plugin together with maven for over a year now and it's just been in the last few months that I've been getting this issue.

Turning up the log severity for the Scala compiler did not provide any more diagnostics.

The solution to my problem seems to be to add the scala compiler as a provided dependency in all of my pom files. I went for provided so that IntelliJ links it in but the resulting assembly doesn't redistribute the compiler.

This gets rid of the need to add the scala-compiler.jar to any module.

I'll let you know if I run into any more issues on this front.

Comment actions Permalink

Yes, it's good to know what versions of the run time and compiler you are using. Incidentally, if you check the tick boxes on the facet configuration page to use the compiler and scala lib from the plugin directory, you get a version clash with Predef (4.1 vs. 5). I've seen this happen when cross-compiling Scala 2.8 and 2.7.7.


Please sign in to leave a comment.