如何在Java中修复NoSuchMethodError

时间:2019-04-22 17:40:43

标签: java eclipse maven nosuchmethoderror

我正在尝试运行JDA Discord Bot,但出现此错误:

[JDA MainWS-ReadThread] INFO net.dv8tion.jda.core.requests.WebSocketClient - Connected to WebSocket
[JDA MainWS-ReadThread] ERROR net.dv8tion.jda.core.requests.WebSocketClient - There was an error in the WebSocket connection
java.lang.NoSuchMethodError: org.json.JSONArray.iterator()Ljava/util/Iterator;
    at net.dv8tion.jda.core.requests.WebSocketClient.updateTraces(WebSocketClient.java:165)
    at net.dv8tion.jda.core.requests.WebSocketClient.onEvent(WebSocketClient.java:797)
    at net.dv8tion.jda.core.requests.WebSocketClient.handleEvent(WebSocketClient.java:745)
    at net.dv8tion.jda.core.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:903)
    at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:368)
    at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:270)
    at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:990)
    at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:749)
    at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
    at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
    at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

我找不到问题所在

我曾在JDA GitHub上问过,但他们说我必须获取已经拥有的最新org.json。所以我很困惑。

希望有人可以在那里帮助我。

1 个答案:

答案 0 :(得分:0)

实际上,org.json.JSONArray.iterator()从一开始就不存在,但是was added later

您的pom.xml看起来不错,但是引用库 中,有 json-simple-1.1.1.jar而不是json-20180813.jar

右键单击项目,然后选择 Maven>更新项目...