I just started using a new Linux (Ubuntu) notebook computer and upgraded to sbt 1.2.0 and Scala 2.12.6. I am trying to run a test driver called ResolutionTest, which is a case object with a main function. Same thing I have been doing for years on my old notebook, and it also runs fine on my office Linux desktop machine. But when I run it, I get a java.lang.NoSuchMethodError (see below). Any clue about the problem could be? Thanks.

[success] Total time: 1 s, completed Aug 4, 2018 12:03:08 PM
java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
at trajspec.test.ResolutionTest$.(ResolutionTest.scala:20)
at trajspec.test.ResolutionTest$.(ResolutionTest.scala)
at trajspec.test.ResolutionTest.main(ResolutionTest.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70)
at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101)
at scala.reflect.internal.util.ScalaClassLoader$
at scala.reflect.internal.util.ScalaClassLoader$

Is it possible you need to do a clean build?

Thanks for the suggestion, but I did that several times already.

1 Like

Is that ResolutionTest also compiled with Scala 2.12?

So to be clear, you have one repo that when you do a fresh clone on the linux desktop machine and do sbt run it works, but when you do a fresh clone on the linux laptop sbt run fails? If it’s not as black and white can you try to minimize the differences?

Actually, I have a git repo on my work Linux machine, and I have an rsync’d copy on my Linux notebook. I’ve been doing this for years, but I recently started using a new notebook. Both my home and work machines are now running the same software with the same Linux and sbt versions (2.12.6 and 1.2.0).

After I replied to your earlier post I realized that I was doing “sbt clean” but not “sbt test:clean”. So I executed the latter as well. Now I am getting a java.lang.ClassNotFoundException rather than a java.lang.NoSuchMethodError, and it is at a slightly different location in the code. Just to be sure, I then removed my entire target directory and recompiled. I don’t understand how it can compile just fine and then not find the class at runtime. Maybe something is wrong with my installation. Or I am making some incredibly dumb mistake!

I figured it out. I was using a jar file from another project in my sbt lib directory. That jar file was compiled with Scala 2.11, and I forgot to recompile it with 2.12.

Weird. I just started getting the NoSuchMethodError in a certain project!

1 Like

Somehow xsbt-web-plugin didn’t clean up some 2.11 jars