• 周六. 10 月 5th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

CXF java.lang.NoSuchMethodError Error resolution

King Wang

1 月 3, 2022

NoSuchMethodError It’s a runtime error , This error usually does not occur at compile time .
Now that it compiles successfully , It means that the method itself exists , The class of the method also exists , And all of them can be quoted to .

So why is this error still happening ?
The method itself exists , The class of the method also exists , Then this error will occur at runtime ,
It can only be said that there is no such method in the class referenced by the runtime .
It’s a bit awkward to say , To put it simply , There are at least two classes with the same name A and B, among A There is one need Method ,B There is no such way . Compile time , The compiler finds the required classes under the dependency path A perhaps B, Then compile through .
But in execution , To call A.need() When the method is used , because A and B The same name , Wrong call B.need() Method , This method does not exist in itself , It’s natural that NoSuchMethodError This mistake

terms of settlement :
Through analysis, we can find , In fact, the root cause of the problem is class conflict , That is, there are multiple classes that meet the conditions A,B,C..
This happens when you reference a library or jar when , It refers to multiple versions at the same time .
The solution is simple , Find the throw NoSuchMethodError This abnormal class , Then find out all the Jar, Then keep the right way , Put the others jar Delete , That’s all right. .

Attention to detail operation :

If you want to in eclipse Find all of the jar Bag words ,ctr+shit+t After entering the class name, the corresponding Jar Bag location ; Double click in jar After package ,ctr+o Check to see if there’s that way ; If there are any , We didn’t know it was right jar It’s packed ;
If you don’t know which is right jar, Please use the programmer will :
Rule out the law Try it one by one , Who doesn’t report a mistake , Who is right !

about cxf for , The general situation is xmlschema he xmlschma-core Two jar Conflict , We reserve the core, Another delete will do .

发表回复