NoSuchMethodError after cleaning the project

5.5k views Asked by At

I'm currently getting this error:

java.lang.NoSuchMethodError: org.json.JSONObject.keySet()Ljava/util/Set;
at ee.ut.cs.Parser.accessLint(Parser.java:39)

I have tried cleaning the project to no awail.

I suspect I have an error in the src/plugin/parse-htmlraw/build.xml while creating the jar file but I'm not certain. I understand that this error is because the function does not exist at runtime, but the object is created which means that the class is there, just not that function. I decompiled the .class file in created jar and it has the necessary functions.

Code is available at https://github.com/jaansusi/WCAGgrader

Q: What is wrong with the build that produces this error?

The problem is that even if I put the necessary class files in the jar I create, they are not linked correctly and the class that's called in the jar can't locate functions inside the other classes. The class object JSONObject is created but the functions inside the JSONObject class can't be found.

3

There are 3 answers

0
Parag Gupta On BEST ANSWER

Check for the version you have used. There might be a case where 2 different versions are being used which in turn causes this error.

0
royashcenazi On

If you do not find the problematic version, there is a possibility you get it (especially if you are using Spring) from the following dependency -

<artifactId>android-json</artifactId>
<groupId>com.vaadin.external.google</groupId>

excluding it worked for me,

  • An easy way of analyzing dependencies is the maven-helper plugin in Intellij, see here
0
liukaihui On

To their own maven local repository com\Google\code\gson\gson, see if there are two or more version about json, will have to do is to delete the old, and remember to look at any other place in the project is introduced into the old version of the dependence, if any, change the old version of the dependence to the new version is perfectly solved this problem