I changed the return type of one method in an interface in a library. Previously it was void and I modified it to return an object. I did not change the code in my module as I did not want to do anything with the returned object(it was for a different module) I compiled my module with the new library jar and ran unit tests which ran fine but when I pushed the jar along with the library jar to production and ran the module, i get java.lang.NoSuchMethodError for the method I changed on the interface. I modified the interface as well as the implementation, both are in the library jar and I use spring annotations to inject the implementation object in my module. What is the possible cause of this problem?
In the Java bytecode the return type of a method is part of the method signature, and it differentiates between two methods with the same name and same parameters (this is something that you cannot do in the Java language). So your code which calls this method somehow wasn't recompiled and it still tries to call the method which returns void.
It sounds like you haven't recompiled everything, or haven't pushed all the recompiled jar files to prod.
Additionally, you didn't specify whether you restarted the server. If you've got some sort of "hot restart" going on, you'll have to have configured all the classloaders very carefully to get it right. If you can restart the container completely, that may help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With