You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our hibernate modules we do not have jcache dependencies in the classpath. When I upgrade hazelcast version to 3.7-SNAPSHOT, I got java.lang.NoClassDefFoundError: javax/cache/Cache error when mocking HazelcastInstance. Here is a simple reproducer from a hibernate test :
@RunWith(HazelcastSerialClassRunner.class)
@Category({QuickTest.class, ParallelTest.class})
public class HazelcastQueryResultsRegionTest {
private HazelcastInstance instance;
@Test
public void testPut() {
instance = mock(HazelcastInstance.class);
}
}
The text was updated successfully, but these errors were encountered:
Seems that since ICache is at the signature of HazelcastInstance, Mockito try to load javax.cache.Cache at some point while creating proxy instance.
I have not thought about it much yet but the easiest solution/workaround (should we for such cases?) might be changing the signature to Object getCache(String name) at the signature of HazelcastInstance but this will enforce users to explicitly cast to Cache on their code.
We can also change the signature as <C> C getCache(String name) so when the left-hand variable is javax.cache.Cache typed, there will be no explicit casting required but still this allows casting to any type which is not javax.cache.Cache.
I had also thought this at the beginning of the PRD:
I can also confirm this issue when using Hazelcast 3.7-EA with even the simplest Spring Boot application (create a project from http://start.spring.io/ with no dependencies selected, add Hazelcast dependency version 3.7-EA to your POM, add a @Bean method that instantiates a HazelcastInstance to the main class, startup the application, observe java.lang.NoClassDefFoundError: javax/cache/Cache error). Only solution for Spring Boot users I have found so far is to add the cache-api as a dependency or downgrade to 3.6.x.
In our hibernate modules we do not have jcache dependencies in the classpath. When I upgrade hazelcast version to
3.7-SNAPSHOT
, I gotjava.lang.NoClassDefFoundError: javax/cache/Cache
error when mockingHazelcastInstance
. Here is a simple reproducer from a hibernate test :The text was updated successfully, but these errors were encountered: