Affects: Version 5.0 and above
Issue:
Failure in BeanUtils.copyProperties(source, target)
Stack Trace:
Exception in thread "main" java.lang.NullPointerException
at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:69)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.
Initial Analysis:
findBridgedMethod(Method bridgeMethod)method ofBridgeMethodResolverwas refactored as part of Spring 5.0 release.- Whenever this method is invoked for getting
writeMethodToUseforpropertyName=class, it results in Null Pointer exception asisBridge()method ofbridgeMethodis invoked which is null.
Comment From: jhoeller
It seems that you're running spring-beans-4.3.x against spring-core-5.x.x there. We don't support that, the Spring Framework module versions need to be in sync. Please make sure that your classpath is consistent in that respect.
spring-beans-5.x.x has corresponding non-null guards at that position so bypasses the BridgeMethodResolver call upfront.
Comment From: DhavalShewale
@jhoeller I am using spring boot 2.2.1-RELEASE so the probability of having different versions of spring-core and spring-beans is unlikely
Comment From: jhoeller
While I consider it unlikely as well, your stacktrace definitely hints at spring-beans-4.3.x being in action there since that's where no such null check is present and that's where the line numbers match. Compare GenericTypeAwarePropertyDescriptor.java in a more recent version and you'll see what I mean.
Comment From: jhoeller
On a related note, the line numbers for CachedIntrospectionResults and BeanUtils do not match either. For the methods seen in the stacktrace above, the line numbers are in the ballpark of where they were in 4.x, quite far from where they are now in 5.x and 5.2.x in particular. Since all three of those classes come from spring-beans, it does look like an old version of that jar is around somewhere.
Comment From: DhavalShewale
@jhoeller Hey, you were right about this.
spring-beans-3.2.18.RELEASE.jar was getting imported from another project in pom and strangely maven was omitting spring-beans-5.2.1.RELEASE.jar instead of omitting the previous one.
Thanks for your quick feedback, else I would have wasted hours to figure this out. :)