Running my program leads to java.lang.NoSuchMethod

2019-07-09 12:03发布

问题:

I am trying to run an open-source program called LinkedIn Norbert (https://github.com/linkedin/norbert) in Scala 2.8.1. I have added all the jar files so the program compiles, but when I try to run class com.linkedin.norbert.javacompat.network.RunNorbertSetup in examples/src/main/java, I get the following error:

Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
    at com.linkedin.norbert.jmx.JMX$.name(JMX.scala:59)
    at com.linkedin.norbert.cluster.ClusterClient$$anon$1.<init>(ClusterClient.scala:56)
    at com.linkedin.norbert.cluster.ClusterClient$class.$init$(ClusterClient.scala:55)
    at com.linkedin.norbert.cluster.zookeeper.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:22)
    at com.linkedin.norbert.cluster.ClusterClient$.apply(ClusterClient.scala:33)
    at com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:23)
    at com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:21)
    at com.linkedin.norbert.javacompat.network.RunNorbertSetup.configCluster(RunNorbertSetup.java:115)
    at com.linkedin.norbert.javacompat.network.RunNorbertSetup.main(RunNorbertSetup.java:21)

What would I need to do to get past this error? I've looked at other Stack Overflow and forum threads, and these have not helped.

FYI: I built the program with SBT.

Thanks so much, Rebecca

回答1:

Run a "clean" instead of build. Remove all the build and bin folders from the project directory too.



回答2:

The solution was to put the relevant class in the classpath.