Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix NoSuchMethodError?

Tags:

testing

scala

I use Scala 2.10.0RC1 and sbt 0.12.1. What causes and how can I fix this runtime error (runs fine on 2.9.2)?

The exact error message is:

java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/Object;)Lscala/Tuple2;

like image 983
user1779032 Avatar asked Oct 27 '12 09:10

user1779032


People also ask

How do you get NoSuchMethodError?

Dig into the do. something code, decompiling it if you don't have the source, and see what is actually thrown by it. Possibly if the exception gets thrown it might get wrapped in another exception. Make sure that anything thrown by the method does not get eaten (including by your own logging of it).

What is a no such method error?

NoSuchMethodError is a runtime error in Java which occurs when a method is called that exists at compile-time, but does not exist at runtime. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java. lang.

How do you fix No class Def Found error?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.


1 Answers

You're running the code with the wrong Scala version. This can have several causes:

  • misconfiguration of the project with sbt – search for 2.9.2 in config files
  • stale cache used by sbt – sbt reboot
  • something else?

If you meticulously check all your sbt configuration files for 2.9.2 and then wipe out all caches, things should run better. Dependencies usually have a version number in the name of the jar file, so running a find on your system will likely point you to the ones you missed.

like image 96
iwein Avatar answered Oct 02 '22 21:10

iwein