2
votes

I have implemented successfully the reflectionEquals method, with a list of excluded fields.

return  EqualsBuilder.reflectionEquals(this, obj, new String[] {"files", "notes", "status"});

However, I recently compiled my program on Java 1.5 and now I get the following error when the program hits the above line:

java.lang.NoSuchMethodError: org.apache.commons.lang.builder.EqualsBuilder.= reflectionEquals(Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/String;)Z

If anyone has an insight on why the method does not exist at runtime, I would appreciate it

3

3 Answers

8
votes

Every NoSuchMethodError that I've ever encountered has (eventually) been found to be a mismatch between the version of an external library on the classpath at compile time vs. the version of the library on the classpath at runtime (i.e. - in this case, you would have a different version of apache commons on your classpath when the application is compiled than when it is running.)

The method was definitely there when your code was compiled - or a compiler error would've been thrown.

Check the versions of commons-lang.jar on your classpaths - I'm betting you'll find a mismatch.

It's worth noting that this is NOT a MISSING jar file - that would throw a ClassNotFoundException (maybe eventually followed by a NoClassDefFoundError.)

1
votes

This is likely a var args problem. Be sure to recompile everything in java 1.5 and be sure you are running it on java 1.5, and be sure you reference the same jar at compilation as at runtime.

0
votes

You may have an older version on your runtime classpath.

Get the latest version of Apache Commons Lang