Search code examples
javamavenexceptiongemfiregeode

ClassCastException when creating geode ClientCacheFactory object


I am using gemfire and trying to load client cache using apache geode in my maven project. When ClientCacheFactory is created, I am getting a ClassCastException

java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLogger cannot be cast to org.apache.logging.log4j.core.Logger
  at org.apache.geode.logging.log4j.internal.impl.Log4jLoggingProvider.getRootLoggerContext(Log4jLoggingProvider.java:105) ~[geode-log4j-9.10.5.jar:na] 

  at org.apache.geode.logging.log4j.internal.impl.Log4jloggingProvider.getConfiguration (Log4jloggingProvider. java:109) ~[geode-log4j-9.10.5.jar:na]

at org.apache.geode.logging.log4j.internāl.impl.log4jloggingProvider.isUsingGemFireDefaultConfig (Log4jloggingProvider.java:94) ~[geode-log4j-9.10.5.jar:na]

at org.apache.geode.logging.log4j.internal.impl.Log4jloggingProvider.shouldUpdateLoglevels (Log4jloggingProvider.java:143) ~[geode-logj-9.10.5.jar:na]

at org.apache.geode.logging.log4j.internal.impl.log4jloggingProvider.configure (Log4jLoggingProvider.Java:121) "[geode-log4j-9.10.5.jar:na]

at org.apache.geode.logging.internal.Configuration.configChanged (Configuration. Java:143) " [geode-core-9.10.5.jar:na]

at org.apache.geode.logging.internal.Configuration. initialize (Configuration.java:132) " [geode-core-9.10.5.jar:na]

at org.apache.geode.logging.internal.LoggingSession.createSession (LoggingSession.java:69) "[geode-core-9.10.5.jar:na]

at org.apache.geode.distributed.internal.InternalDistributedSystem.initialize (InternalDistributedSystem. java:704) ~[geode-core-9.10.5.jar:na]

at org.apache.geode.distributed.internal. InternalDistributedSystem.access$200 (InternalDistributedSystem. java:135) ~[geode-core-9.10.5.]ar:na

at org.apache.geode.distributed.internal. InternalDistributedSystemșBuilder.build (InternalDistributedSystem. java:3036) ~[geode-core-9.10.5.jar:na]

at org.apache.geode.distributed. internal.InternalDistributedSystem.connectInternal (InternalDistributedSystem.java:290) ~[geode-core-9.10.5.jar:na]

at org.apache.geode.distributed.înternal.InternalDistributedSystem.connectInternal (InternalDistributedsystem. java:216) ~[geode-core-9.10.5.jar:na]

at org.apache.geode.cache.client.ClientCacheFactory.connectInternalDistributedSystem (ClientCacheFactory. java:280) ~ [geode-core-9.10.5.jar:na]

at org.apache.geode.cache.client.ClientCacheFactory.basicCreate (ClientCacheFactory.java:250) - [geode-core-9.10.5.jar:na]

at org.apache.geode.cache.client.ClientCacheFactory.create (ClientCacheFactory. java:216) "[geode-core-9.10.5.jar:na]
.....

I have tried removing log4j-over-slf4j,log4j-api and log4j-core and tried adding slf4j-log4j12 but still I get this exception. Now I know geode-core internally includes log4j, so I have excluded log4j and log4j-to-slf4j dependencies as well. But issue still persists. It would be really helpful if I could get some pointers regrading the exception.

Currently I have the following dependencies : 1.log4j-slf4j-impl 2.log4j-api 3.log4j-core 4.log4j-over-slf4j 5.slf4j-api 6.slf4j-log4j12

I am using geode-core-9.10.5 with both geode-log4j and geode-logging included as well.


Solution

  • For anyone who might face this issue in future, it was because of the geode-log4j jar. I had another folder where I add slf4j jars in the project. Due to technical reasons, I am not allowed to remove those.Once I removed the jar this exception disappeared.