Forum Stats

  • 3,836,753 Users
  • 2,262,182 Discussions


LinkageError: when resolving interface method “com.hazelcast.core.IMap.getLocalMapStats()"

Vikrant Korde.
Vikrant Korde. Member Posts: 338 Bronze Badge

We have a springboot project. It generates EAR and same goes in weblogic. Sometimes while starting the application we observe below log in the log file.

Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "com.hazelcast.core.IMap.getLocalMapStats()Lcom/hazelcast/monitor/LocalMapStats;" the class loader (instance of <bootloader>) of the current class, java/lang/Object, and the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) for the method's defining class, com/hazelcast/core/IMap, have different Class objects for the type com/hazelcast/monitor/LocalMapStats used in the signature
at java.lang.invoke.MethodHandleNatives.resolve(Native Method) ~[?:1.8.0_141]
at java.lang.invoke.MemberName$Factory.resolve( ~[?:1.8.0_141]
at java.lang.invoke.MemberName$Factory.resolveOrFail( ~[?:1.8.0_141]
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail( ~[?:1.8.0_141]
at java.lang.invoke.MethodHandles$Lookup.findVirtual( ~[?:1.8.0_141]
at io.micrometer.core.instrument.binder.cache.HazelcastIMapAdapter.resolveIMapMethod( ~[micrometer-core-1.5.7.jar:1.5.7]
at io.micrometer.core.instrument.binder.cache.HazelcastIMapAdapter.<clinit>( ~[micrometer-core-1.5.7.jar:1.5.7]

We are using Hazelcast 3.12.9 and many other dependencies in our project. I do understand that java.lang.LinkageError happens when there are 2 or more versions found for the class. As per above message it seems there are 2 versions of com.hazelcast.monitor.LocalMapStats is getting loaded. The questions that are not answered are

  1. How to find the jar which are having 2 versions of com.hazelcast.monitor.LocalMapStats class?
  2. Is there any role of loaders and <weblogic/utils/classloaders/ChangeAwareClassLoader> in this error?
  3. There is another way to define to give priority to web application jar compared to weblogic jars by specifying prefer-web-inf-classes = false (more details

On Oracle support we found an article 1316723.1 which says that we should not use wls:prefer-web-inf-classes in your weblogic.xml. This is an old practice and we should use filtering classloader in weblogic-applicaton.xml.

However problem is still not resolved. It looks like some version incompatibility issue between micrometer-core-1.5.7.jar and com.hazelcast-3.12.9. Micrometer needs Hazlecast with version 4.X. But somehow my project is loading hazelcast 3.12.9.

Please guide on how to get rid of this issue.