I'm getting a NoSuchMethodError
error when running my Java program. What's wrong and how do I fix it?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I had a similar problem with my Gradle Project using Intelij. I solved it by deleting the .gradle (see screenshot below) Package and rebuilding the Project. .gradle Package
I have just solved this error by restarting my Eclipse and run the applcation. The reason for my case may because I replace my source files without closing my project or Eclipse. Which caused different version of classes I was using.
I ran into similar issue.
Finally I identified the root cause was changing the data type of variable.
Employee.java
--> Contains the variable (EmpId
) whose Data Type has been changed fromint
toString
.ReportGeneration.java
--> Retrieves the value using the getter,getEmpId()
.We are supposed to rebundle the jar by including only the modified classes. As there was no change in
ReportGeneration.java
I was only including theEmployee.class
in Jar file. I had to include theReportGeneration.class
file in the jar to solve the issue.The problem in my case was having two versions of the same library in the build path. The older version of the library didn't have the function, and newer one did.
I feel your pain. You can learn programming out of a book, but when it comes to working with Eclipse or Visual Studio, its a ^&^&'n nightmare to do something simple like add a library. Everybody expects you to know how to use it and if you don't they downvote your question. The problem is, if you don't work in an office or know anyone who you can ask these questions, then its almost impossible to figure this stuff out. Anyway...
I was having your problem, and this is how I fixed it. The following steps are a working way to add a library. I had done the first two steps right, but I hadn't done the last one by dragging the ".jar" file direct from the file system into the "lib" folder on my eclipse project. Additionally, I had to remove the previous version of the library from both the build path and the "lib" folder.
If anyone knows of a more proper way to add/update a library, please chime in.
Step 1 - Add .jar to build path
Step 2 - Associate sources and javadocs (optional)
Step 3 - Actually drag .jar file into "lib" folder (not optional)
Just adding to existing answers. I was facing this issue with tomcat in eclipse. I had changed one class and did following steps,
Cleaned and built the project in eclpise
mvn clean install
Still I was facing same error. Then I cleaned tomcat, cleaned tomcat working directory and restarted server and my issue is gone. Hope this helps someone