Test execution in IntelliJ ClassNotFoundException
I have tried many different run configurations, but whatever I do, I get this exception when running specs2 tests in IntelliJ for scala.
Always failing to find a class ending with a character $
. I checked - and there really is no such class file. There AppControllerIT.class and many classes like AppControllerIT $ innerFunctionOrclass.clas but not AppControllerIT $ .class
Any ideas?
Thank!
com.haha.market.api.e2e.controllers.AppControllerIT$
java.lang.ClassNotFoundException: com.haha.market.api.e2e.controllers.AppControllerIT$
STACKTRACE
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
org.specs2.reflect.Classes$$anonfun$loadClassEither$1.apply(Classes.scala:140)
org.specs2.reflect.Classes$$anonfun$loadClassEither$1.apply(Classes.scala:140)
org.specs2.control.ActionT$$anonfun$safe$1.apply(ActionT.scala:89)
org.specs2.control.ActionT$$anonfun$reader$1$$anonfun$apply$6.apply(ActionT.scala:80)
org.specs2.control.Status$.safe(Status.scala:100)
source to share
The signed classes are $
generated from compiled Scala objects. This means that you can have a specific object like this:
package com.haha.market.api.e2e.controllers
object AppControllerIT {
}
From your error, it seems that an older compiled artifact or library (?) Is polluting your classpath. Try to clean the project ( mvn clean
or sbt clean
) first. Then try cleaning up any libraries you have in the project inside IntelliJ. IntelliJ sometimes caches multiple versions of the same libraries, which can cause confusion at runtime. To clean them up, go to "File -> Project Structure" in IntelliJ and manually remove any duplicate libraries you may have.
source to share