I am new to spring data gemfire/apache geode. I am getting the following error. Can anyone explain what is wrong with my configuration?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache' defined in org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at com.oreedoo.restful.RestfulGemFireApplication.main(RestfulGemFireApplication.java:32) [main/:na] Caused by: java.lang.ExceptionInInitializerError: null at org.apache.geode.distributed.internal.InternalDistributedSystem.(InternalDistributedSystem.java:126) ~[geode-core-1.2.1.jar:na] at org.springframework.data.gemfire.util.DistributedSystemUtils.getDistributedSystem(DistributedSystemUtils.java:86) ~[spring-data-geode-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.data.gemfire.client.ClientCacheFactoryBean.getDistributedSystem(ClientCacheFactoryBean.java:218) ~[spring-data-geode-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.data.gemfire.client.ClientCacheFactoryBean.resolveProperties(ClientCacheFactoryBean.java:197) ~[spring-data-geode-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.data.gemfire.CacheFactoryBean.afterPropertiesSet(CacheFactoryBean.java:174) ~[spring-data-geode-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] ... 16 common frames omitted Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLogger cannot be cast to org.apache.logging.log4j.core.Logger at org.apache.geode.internal.logging.LogService.init(LogService.java:81) ~[geode-core-1.2.1.jar:na] at org.apache.geode.internal.logging.LogService.(LogService.java:72) ~[geode-core-1.2.1.jar:na] ... 23 common frames omitted
Here is my configuration:
@SpringBootApplication
@ClientCacheApplication(name = "ClientGemFireApplication", logLevel =
"config")
@EnableEntityDefinedRegions(basePackageClasses = Subscription.class,
clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireRepositories
@Import(GemFireConfiguration.class)
public class RestfulGemFireApplication {
public static void main(String[] args) {
SpringApplication.run(RestfulGemFireApplication.class, args);
}
@Bean
ApplicationRunner run(SubscriptionRepository subscriptionRepository) {
return args -> {
Subscription sub1 = new Subscription("Sub1", null, null, null, null, null, null, null, null, null, null);
Subscription sub2 = new Subscription("Sub2", null, null, null, null, null, null, null, null, null, null);
Subscription sub3 = new Subscription("Sub3", null, null, null, null, null, null, null, null, null, null);
System.out.println("Before accessing data in GemFire...");
asList(sub1, sub2, sub3).forEach(subscription -> System.out.println("\t" + subscription));
System.out.println("Saving Sub1, Sub2 and Sub3 to GemFire...");
subscriptionRepository.save(sub1);
subscriptionRepository.save(sub2);
subscriptionRepository.save(sub3);
System.out.println("Lookup each subscription by accessId...");
asList(sub1.getAccessMethodId(), sub2.getAccessMethodId(),
sub3.getAccessMethodId())
.forEach(accessMethodId -> System.out.println("\t" +
subscriptionRepository.findSubscriptionByAccessMethodId(accessMethodId)));
};
}
}
@Configuration
public class GemFireConfiguration {
public Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name",
RestfulGemFireApplication.class.getSimpleName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", "config");
return gemfireProperties;
}
@Bean
public CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
gemfireCache.setProperties(gemfireProperties());
return gemfireCache;
}
@Bean
ClientRegionFactoryBean<String, Subscription> subscriptionRegion(final
GemFireCache cache) {
ClientRegionFactoryBean<String, Subscription> subscriptionRegion = new
ClientRegionFactoryBean<>();
subscriptionRegion.setCache(cache);
subscriptionRegion.setName("Subscription");
subscriptionRegion.setClose(false);
subscriptionRegion.setShortcut(ClientRegionShortcut.PROXY);
subscriptionRegion.setPersistent(false);
return subscriptionRegion;
}
}
@Region("Subscription")
@Data
public class Subscription {
@Id @NonNull//FIXME primary key
String accessMethodId;
String activationDttm;
String customerAverage;
String customerId;
String marketSegmentation;
String subscriptionOffering;
String subscriberNum;
String subscriptionStatus;
String subscriptionType;
String terminatedDttm;
String usageSegmentation;
@PersistenceConstructor
public Subscription(String accessMethodId, String activationDttm, String
customerAverage, String customerId,
String marketSegmentation, String subscriptionOffering, String
subscriberNum, String subscriptionStatus,
String subscriptionType, String terminatedDttm, String
usageSegmentation) {
super();
this.accessMethodId = accessMethodId;
this.activationDttm = activationDttm;
this.customerAverage = customerAverage;
this.customerId = customerId;
this.marketSegmentation = marketSegmentation;
this.subscriptionOffering = subscriptionOffering;
this.subscriberNum = subscriberNum;
this.subscriptionStatus = subscriptionStatus;
this.subscriptionType = subscriptionType;
this.terminatedDttm = terminatedDttm;
this.usageSegmentation = usageSegmentation;
}
}