Comments (29)
Thanks for the update John and glad this is working as expected.
@kirklund @metatype I think the generated pom metadata can be improved for this use case. Because log4j-core
is specified explicitly in more than one module (besides geode-core
) we have to exclude it explicitly for every modules we declare, see this commit though I believe the exclude on geode-wan
is unnecessary.
If log4j-core
was specified only in geode-core
, then we could exclude it from there and simplify the steps required to get log4j out of the way. Thoughts?
from spring-boot-data-geode.
Hacking a bit with Apache Geode 1.9.0
where this particular issue has been fixed, it is still happening with a call to Log4jAgent#getRootLoggerContext
:
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.log4j.Log4jAgent.getRootLoggerContext(Log4jAgent.java:91) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.log4j.Log4jAgent.getConfiguration(Log4jAgent.java:95) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.log4j.Log4jAgent.isUsingGemFireDefaultConfig(Log4jAgent.java:80) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.log4j.Log4jAgent.shouldUpdateLogLevels(Log4jAgent.java:129) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.log4j.Log4jAgent.configure(Log4jAgent.java:107) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.Configuration.configChanged(Configuration.java:152) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.Configuration.initialize(Configuration.java:141) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.internal.logging.LoggingSession.createSession(LoggingSession.java:65) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.java:762) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:446) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:432) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.distributed.internal.InternalDistributedSystem.connectInternal(InternalDistributedSystem.java:257) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.distributed.DistributedSystem.connect(DistributedSystem.java:164) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.cache.client.ClientCacheFactory.basicCreate(ClientCacheFactory.java:243) ~[geode-core-1.9.0.jar:na]
at org.apache.geode.cache.client.ClientCacheFactory.create(ClientCacheFactory.java:214) ~[geode-core-1.9.0.jar:na]
at org.springframework.data.gemfire.client.ClientCacheFactoryBean.createCache(ClientCacheFactoryBean.java:391) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:324) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:268) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
from spring-boot-data-geode.
@snicoll I agree that log4j-core should be flagged as optional for geode-core. When I brought it up with other Geode developers they preferred keeping it as required until the code using log4j-core is moved to a new submodule called geode-log4j
. I'll continue to push for either marking it optional or moving it to a submodule as soon as possible. Geode/GemFire used to be a single monolithic JAR file with proprietary logging (API and backend) and modularizing it is progressing.
from spring-boot-data-geode.
I've tried to configure Log4j so that it's used as the logging framework for the whole application as it feels more clean than just having both logback and log4j on the classpath. We document this use case and is supported by Spring Boot so that could be an alternative while Geode removes their hard reference to log4j.
Unfortunately, doing that gives a non compliant log output because geode itself ships a log4j2.xml
configuration in its jar. This can be demonstrated by setting the log4j2.debug
system property on a vanilla app:
DEBUG StatusLogger Apache Log4j Core 2.11.2 initializing configuration XmlConfiguration[location=jar:file:/Users/snicoll/.m2/repository/org/apache/geode/geode-core/1.9.0/geode-core-1.9.0.jar!/log4j2.xml]
I've created GEODE-6964
from spring-boot-data-geode.
Thanks for the feedback. To summarize the current state of affairs, Geode 1.9 still exhibits the problem of using slf4j and even if we switch to use log4j as the main logging platform, the logging format is overridden by the presence of a logging config in Geode itself.
Would it be possible to get some feedback on GEODE-6964? Switching to log4j is something we are willing to do as a temporary workaround but I am not sure the override of the logging format is acceptable.
from spring-boot-data-geode.
geode-core
is used in several different contexts:
- For a server/locator started by gfsh
- For a server/locator started by springboot
- For a client application
In scenarios #2 and #3 the default log4j configuration included in the jar file is unexpected.
Perhaps with a combination of boms + reorganizing modules we can accommodate all the usages. For example, move the log4j configuration into a separate jar that is on the class path via geode-dependencies.jar
but not pulled in by geode-client.bom
.
from spring-boot-data-geode.
CC @snicoll - FYI
@metatype, @jdeppe-pivotal, @kirklund - 1 more thought... I could back port the changes to clean up the Logging (with Log4j) in SBDG 1.1
if the fix in Apache Geode 1.9
was back ported to Apache Geode 1.6
in a 1.6.1
release.
If this cannot be done, for whatever reason, then this will have to wait until SBDG 1.2
, when SBDG is based on SD Moore/2.2
, which is based on Apache Geode 1.9
.
Food for thought.
from spring-boot-data-geode.
@jxblum I'll try back-porting this next week and provide an update (it's actually about 12 commits spanning GEODE-2644 and GEODE-6122).
@snicoll geode-core
is the only module with log4j-core
imports. The other modules don't actually contain any code that uses log4j-core
though they do depend on geode-core
so I suppose it's a transitive dependency.
Looks like I have good support to move the code that depends on log4j-core
to its own sub-module so I hope to complete that soon.
from spring-boot-data-geode.
I can see the starter overrides the core Spring Boot starter to exclude the following dependency
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
Adding another starter to my empty app (that is the web starter + the geode starter) fixes the log above but I get this error on startup then:
2019-07-15 14:26:20.101 ERROR 25255 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/data/gemfire/cache/config/GemfireCachingConfiguration.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1674) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1249) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:257) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1474) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1431) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 19 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.geode.internal.cache.GemFireCacheImpl.<clinit>(GemFireCacheImpl.java:255) ~[geode-core-1.6.0.jar:na]
at org.apache.geode.cache.client.ClientCacheFactory.getAnyInstance(ClientCacheFactory.java:626) ~[geode-core-1.6.0.jar:na]
at java.util.Optional.orElseGet(Optional.java:267) ~[na:1.8.0_202]
at org.springframework.data.gemfire.client.ClientCacheFactoryBean.fetchCache(ClientCacheFactoryBean.java:172) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:317) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:268) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at java.util.Optional.orElseGet(Optional.java:267) ~[na:1.8.0_202]
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:796) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:108) ~[spring-data-geode-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 31 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:82) ~[geode-core-1.6.0.jar:na]
at org.apache.geode.internal.logging.LogService.<clinit>(LogService.java:73) ~[geode-core-1.6.0.jar:na]
... 41 common frames omitted
from spring-boot-data-geode.
The immediate culprit I can see is LogService
that assumes that the Logger
interface is the actual Log4j implementation, preventing any use of slf4j and forces Log4j2 as the logging platform of the app.
Looking at master
, it looks like this behaviour has been fixed so an upgrade to the latest may improve the integration with Spring Boot.
from spring-boot-data-geode.
Thank you @snicoll for spending some time on this. I will get back to reviewing these Issues and your comments that you filed shortly.
from spring-boot-data-geode.
@snicoll - Regarding this comment above...
And, specifically...
Looking at master, it looks like this behaviour has been fixed so an upgrade to the latest may improve the integration with Spring Boot.
FYI, I do have an SBDG 1.2.x
branch prepared in my clone for this repo, with SBDG rebased on Spring Boot 2.2
, Spring Data Moore along with Spring Data for Apache Geode 1.9.0
.
If you recall, when I started this project (~June 2017), SBDG 1.0
was based on Spring Boot 2.0
, Spring Data Kay (or SDG 2.0
) and Apache Geode 1.2
(which was the current GA versions of each dependency at that time; also SDG Kay/2.0
was based on Apache Geode 1.2
as well).
To keep the SBDG minor versions (minimally) in-sync with Spring Boot minor versions (even though the major versions differ), I based SBDG 1.1
on Spring Boot 2.1
, Spring Data Lovelace (or SDG 2.1
) which included Apache Geode 1.6.0
(the now current GA versions of the Spring dependencies where SDG Lovelace is based/fixed on Apache Geode 1.6.0
).
After I roll out my SBDG 1.1 GA
, hopefully on the Monday, August 5th as currently scheduled, my intent is to immediately follow that release with a SBDG 1.2.0.M1
, which is based on the latest (non-GA) Spring deps and Apache Geode 1.9
. This aligns nicely with Spring Boot 2.2
, which is based on Spring Data Moore (or SDG 2.2
), which pulls in Apache Geode 1.9
.
I hope this makes sense.
Thanks again for filing GEODE-6964.
from spring-boot-data-geode.
Also note, I am aware that Spring Boot 2.0 reached EOL back in March, as did SD Kay, which is the whole reason I am trying to fast track SBDG 1.1 GA, and also simultaneously get to SBDG 1.2 milestones as quickly as possible.
from spring-boot-data-geode.
Hi @snicoll - I will followup on GEODE-6964 with the Apache Geode community/team.
In addition, I also know it is possible to provide a custom Log4j2 XML configuration file that Apache Geode should pick up and use to log output. That maybe another possible workaround as well for the log format.
Ultimately, I feel very strongly that Apache Geode should not, in anyway, force the use of Log4j, or any other logging provider, on users and that users should have complete control over which logging facade and provider (implementation) they wish to use in their applications along with the technology (e.g. Apache Geode) their applications integrate with.
from spring-boot-data-geode.
As of Apache Geode 1.9.0, all of the code that uses log4j-core is optional
such that if you remove log4j-core from your classpath, none of the code requiring it will be used. Without log4j-core in the classpath, the log4j2.xml will also be ignored. Since log4j-core is a transitive dependency of geode-core, it will be pulled in automatically unless you explicitly exclude it.
Note that log4j-core is a backend similar to logback and log4j-api is a frontend similar to slf4j. You can wire up log4j-api to use logback as its backend and you can wire up slf4j to use log4j-core as its backend.
I have a sample repo called geode-logback in which I write a simple application in GeodeApplicationIntegrationTest. It just creates a Geode Cache.
The dependencies are setup using maven with this pom.xml exclude log4j-core while adding logback-classic and log4j-to-slf4j:
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<version>1.9.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.11.1</version>
</dependency>
We are discussing the possibility of moving all geode-core code that uses log4j-core to a new geode-log4j submodule which would greatly aid in excluding log4j-core in future releases.
Completely removing log4j-core usage from Apache Geode would remove some old features that are currently considered to be required for backwards compatibility. So that removal would likely have to coincide with the release of a major release (2.0).
from spring-boot-data-geode.
Testing this with a recent Geode 1.9.0
and SBDG looks good when I exclude log4j-core
. For example:
dependencies {
compile("org.apache.geode:geode-core:1.9.0") {
exclude module: 'log4j-core'
}
compile ("org.springframework.geode:spring-gemfire-starter:1.1.0.M3") {
exclude module: 'geode-core'
}
runtime("org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE")
runtime("org.springframework.boot:spring-boot-starter-actuator:2.1.6.RELEASE")
}
All the logging is consistent and is not using the log4j.xml
provided by Geode.
from spring-boot-data-geode.
Thanks both, I confirm that my test project works if I exclude log4j-core
. I'd suggest adding the exclude in this project so that the user gets that experience out-of-the-box. This requires an upgrade to Geode 1.9.0. We should make sure to remove the exclude in the samples as well and double check the generated poms have the proper metadata.
@kirklund making the code that uses log4j optional is a great step but I am confused as why log4j
is not flagged as optional in geode-core
(i.e. why do we have to exclude it?).
Without log4j-core in the classpath, the log4j2.xml will also be ignored
I don't think that is an argument. An app may chose to use log4j rather than logback (nothing wrong with that really). When they do with geode-core
on the classpath, the default logging experience is overwritten by the presence of this file. I highly recommend finding an arrangement where such file is not provided. For thee embedded/API use case, I don't think it should be provided at all.
from spring-boot-data-geode.
All-
Unfortunately, this is NOT something I can address in Spring Boot for Apache Geode & Pivotal GemFire (SBDG) 1.1
.
Keep in mind that SBDG 1.1
is based on:
- Spring Framework
5.1
- Spring Data
2.1
(Lovelace) - Spring Session
2.1
(Bean) - Spring Boot
2.1
All of these dependencies line up, i.e. Spring Boot 2.1
pulls in Spring Data Lovelace and Spring Session Bean and is based on Spring Framework 5.1
.
Additionally, Spring Data for Apache Geode & Pivotal GemFire Lovelace/2.1
is based on Apache Geode 1.6
and Pivotal GemFire 9.5.4
. This cannot change since SD Lovelace is already in version 2.1.9.RELEASE
, and Lovelace-SR9
is pulled in by Spring Boot 2.1
.
Furthermore SBDG 1.1
cannot be rebased on Spring Boot 2.2
nor Spring Data Moore/2.2
.
However, the upcoming SBDG 1.2
release line will be based on Spring Boot 2.2
and Spring Data Moore/2.2
, respectively, which pulls in Apache Geode 1.9
& Pivotal GemFire 9.8.3
(currently), which contains the necessary fixes.
The reason why I cannot exclude org.apache.logging.log4j:log4j-core
with SBDG 1.1
is due to:
ERROR SpringApplication Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'calculatorController': Unsatisfied dependency expressed through field 'calculatorService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'calculatorService' defined in file [/Users/jblum/pivdev/spring-boot-data-geode/spring-geode-samples/caching/inline/out/production/classes/example/app/caching/inline/service/CalculatorService.class]: Initialization of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.Region]: Failed to create Region for cache [SquareRoots]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
at example.app.caching.inline.BootGeodeInlineCachingApplication.main(BootGeodeInlineCachingApplication.java:35)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'calculatorService' defined in file [/Users/jblum/pivdev/spring-boot-data-geode/spring-geode-samples/caching/inline/out/production/classes/example/app/caching/inline/service/CalculatorService.class]: Initialization of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.Region]: Failed to create Region for cache [SquareRoots]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
... 19 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.Region]: Failed to create Region for cache [SquareRoots]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
at org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration.lambda$registerRegionBeans$3(CachingDefinedRegionsConfiguration.java:327)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration.registerRegionBeans(CachingDefinedRegionsConfiguration.java:299)
at org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration.access$100(CachingDefinedRegionsConfiguration.java:108)
at org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration$1.postProcessBeforeInitialization(CachingDefinedRegionsConfiguration.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1674)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:330)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:411)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:344)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:337)
at org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration.lambda$registerRegionBeans$3(CachingDefinedRegionsConfiguration.java:306)
... 35 more
Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
at org.apache.geode.internal.logging.LogService.init(LogService.java:82)
at org.apache.geode.internal.logging.LogService.<clinit>(LogService.java:73)
at org.apache.geode.internal.cache.GemFireCacheImpl.<clinit>(GemFireCacheImpl.java:255)
at org.apache.geode.cache.client.ClientCacheFactory.getAnyInstance(ClientCacheFactory.java:626)
at java.util.Optional.orElseGet(Optional.java:267)
at org.springframework.data.gemfire.client.ClientCacheFactoryBean.fetchCache(ClientCacheFactoryBean.java:172)
at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:317)
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:268)
at java.util.Optional.orElseGet(Optional.java:267)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:796)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:108)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 57 more
Therefore, I can only address this in SBDG 1.2
.
from spring-boot-data-geode.
UPDATE:
I am extremely pleased to inform the group that after removing all excludes org.apache.logging.log4j:log4j-to-slf4j
and adding an exclude on org.apache.logging.log4j:log4j-core
that SBDG 1.2
builds successfully!
To see the changes I made to the SBDG project modules, have a look at commit 1d96a4c and commit ac660ae.
Once SBDG 1.1 GA
is released, I will immediately begin SBDG 1.2
development as well as follow the 1.1.0.RELEASE
with a 1.2.0.M1
release right of way, and include the changes recommended by this Issue ticket.
Please respond here with any comments, questions or concerns.
Thank you.
from spring-boot-data-geode.
@snicoll geode-core is the only module with log4j-core imports. The other modules don't actually contain any code that uses log4j-core though they do depend on geode-core so I suppose it's a transitive dependency.
My point is that geode-core
is the only module that uses log4j-core
and yet other modules in geode have an explicit log4j-core
declaration, forcing users to exclude the library several times as described in my previous comment.
If you look at the published pom for geode-cq
for instance, you'll see the <dependencies>
section is as follows:
<dependencies>
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
The second dependency shouldn't be there IMO.
from spring-boot-data-geode.
All-
I found a case where/when org.apache.logging.log4j:log4j-core
is not properly excluded, it can/will still lead to the following Stack Trace:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:122)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'runner' defined in example.app.crm.CustomerServiceApplication: Unsatisfied dependency expressed through method 'runner' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Customers': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: Error occurred when initializing peer cache
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:779)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:520)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1339)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1178)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:877)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:746)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:396)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:125)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 51 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Customers': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: Error occurred when initializing peer cache
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1283)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1203)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:866)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:770)
... 69 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Customers': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: Error occurred when initializing peer cache
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:615)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:603)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1232)
at org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean.setApplicationContext(GemfireRepositoryFactoryBean.java:104)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:120)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:96)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
... 79 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: Error occurred when initializing peer cache
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1806)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1267)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330)
... 97 more
Caused by: java.lang.RuntimeException: Error occurred when initializing peer cache
at org.springframework.data.gemfire.util.RuntimeExceptionFactory.newRuntimeException(RuntimeExceptionFactory.java:119)
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:290)
at java.util.Optional.orElseGet(Optional.java:267)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:801)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:109)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
... 103 more
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.log4j.Log4jAgent.getRootLoggerContext(Log4jAgent.java:91)
at org.apache.geode.internal.logging.log4j.Log4jAgent.getConfiguration(Log4jAgent.java:95)
at org.apache.geode.internal.logging.log4j.Log4jAgent.isUsingGemFireDefaultConfig(Log4jAgent.java:80)
at org.apache.geode.internal.logging.log4j.Log4jAgent.shouldUpdateLogLevels(Log4jAgent.java:129)
at org.apache.geode.internal.logging.log4j.Log4jAgent.configure(Log4jAgent.java:107)
at org.apache.geode.internal.logging.Configuration.configChanged(Configuration.java:152)
at org.apache.geode.internal.logging.Configuration.initialize(Configuration.java:141)
at org.apache.geode.internal.logging.LoggingSession.createSession(LoggingSession.java:65)
at org.apache.geode.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.java:762)
at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:446)
at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:432)
at org.apache.geode.distributed.internal.InternalDistributedSystem.connectInternal(InternalDistributedSystem.java:257)
at org.apache.geode.distributed.DistributedSystem.connect(DistributedSystem.java:164)
at org.apache.geode.cache.client.ClientCacheFactory.basicCreate(ClientCacheFactory.java:243)
at org.apache.geode.cache.client.ClientCacheFactory.create(ClientCacheFactory.java:214)
at org.springframework.data.gemfire.client.ClientCacheFactoryBean.createCache(ClientCacheFactoryBean.java:391)
at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:325)
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:269)
... 107 more
This was running my the Integration Tests for the :spring-geode-samples-boot-configuration
module and having an improper (indirect/transitive) dependency on the log4j-core
lib.
I think this was the same problem @snicoll experienced as well, earlier.
At any rate, properly excluding the log4j-core
dependency does lead to a clean build. However, I am bit concerned if users are using SLF4J and Log4j together, in the same Spring Boot application, that they may have a similar problem.
I have not dug into this issue in detail yet as I have other higher priority items at the moment, but I do wonder what version of the log4j-to-slf4j
dependency would be compatible with both SLF4J and Log4j versions determined by org.springframework.boot:spring-boot-starter-logging
.
NOTE: the spring-boot-starter-logging
is pulling in the org.apache.logging.log4j:log4j-to-slf4j
dependency, which is based on Log4j version, 2.12.0
, here, which also includes dependency management for SLF4J version, 1.7.26
, here.
Apparently, this is causing a problem for the version of Log4j that Apache Geode 1.9.0
is based on, i.e. 2.11.1
, here.
Unfortunately, I also see that the Log4j version has not properly been updated in the latest Geode version (i.e. 1.10
) on develop.
I would hope that if the Apache Geode project was upgraded to the current Log4j version, 2.12.0
, the same as Spring Boot, that this problem should go away. I have not tested this yet. Either way, this should not change our effort to make the log4j-core
dependency optional.
:(
from spring-boot-data-geode.
I do wonder what version of the log4j-to-slf4j dependency would be compatible with both SLF4J and Log4j versions determined by org.springframework.boot:spring-boot-starter-logging.
I don't think the classcast is a problem of incompatible version but rather the fact that Log4jAgent expects the Logger
interface to be the log4j implementation.
When a Spring Boot application runs with its default settings, it provides a wrapper lib for the log4j library (as you've indicated via log4j-to-slf4j
). That tiny wrapper lib provides a dummy implementation for the log4j interfaces that redirects to slf4j.
The problem here is that Geode makes assumption as what the implementation of that interface should be and expect a fully configured log4j environment.
So TL;DR
it's not a problem of incompatible versions and upgrading won't change anything to the problem.
from spring-boot-data-geode.
@jxblum @snicoll Thanks for the info!
I filed GEODE-7050 for the ClassCastException. That's definitely a bug in the Log4JAgent
code.
I filed GEODE-7051 for upgrading Geode's log4j dependencies to 2.12.0.
I'll back-port the fixes for GEODE-7050 and GEODE-7051 to 1.9.x.
Log4JAgent
is only loaded and in use when log4j-core
is in the classpath. The expectation is that if logback
and log4j-to-slf4j
are in the classpath then log4j-core
should be excluded which prevents Log4JAgent
from being loaded or used.
The pom for geode-cq
shows a dependency on log4j-api
, not log4j-core
, which is correct as far as I understand (the code uses Loggers
from log4j-api
):
<dependencies>
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
from spring-boot-data-geode.
The pom for geode-cq shows a dependency on log4j-api, not log4j-core, which is correct as far as I understand (the code uses Loggers from log4j-api):
Arg, sorry about that, I mixed them up. We still need to exclude them for every dependency, which is annoying. If you relied on the presence of log4j-api
via geode-core
rather than defining the dependency again, we could exclude log4j from geode-core
and get a proper setup with the Slf4j replacement.
That's essentially what I was after even though I didn't phrase it properly. Can you please consider that change too?
from spring-boot-data-geode.
@snicoll I added a comment to GEODE-7051 to remove explicit dependency on log4j-api
from all modules other than geode-core
.
Every geode class is using the log4j-api
directly so I'm not sure how helpful this tweak will be. The log4j-to-slf4j
library just backs the log4j api loggers with implementations that invoke slf4j loggers.
I do plan to mark log4j-core
as optional as well (as part of GEODE-7051) and I think this should help the most to enable using logback as the backend.
from spring-boot-data-geode.
Cross linking to Spring Initializer Issue #176.
from spring-boot-data-geode.
Posting link to a recent discussion ([DISCUSS]
email thread) on the Apache Geode Dev Mailing List.
from spring-boot-data-geode.
Running jar in Docker throws NullPointerException where as in command line, it works fine.
The error stack trace is as follows :
Caused by: java.lang.NullPointerException: null
org.apache.geode.internal.logging.LogService.getLogger(LogService.java:62)
org.apache.geode.internal.cache.GemFireCacheImpl.(GemFireCacheImpl.java:264)
... 31 common frames omitted
My pom.xml is as follows:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.11.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.1</version>
<scope>runtime</scope>
</dependency>
<!-- && -->
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<version>1.10.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
What am I missing?
from spring-boot-data-geode.
@vasudeva78 did you solve this issue? I have the same only on Java 11, while using Java 1.8 it works fine!
from spring-boot-data-geode.
Related Issues (20)
- Create a spring-cloud-bindings BindingsPropertiesProcessor for Apache Geode HOT 2
- State project goals in documentation
- Include chapter on Testing in the SBDG reference documentation
- Compatability matrix is not up to date. HOT 1
- Remove link to SDG Version Compatibility Matrix in SBDG Wiki
- Missing geode-pulse Dependency in Documentation
- Compatibility question HOT 3
- Using a sealed class as a data object fails HOT 1
- Inheriting from entity types causes failure when using entity-defined Regions HOT 1
- Exception thrown when parsing spring.session.timeout property with java.time.Duration styling HOT 1
- Improve documentation around overriding dependency versions
- Clarify the use of SDG's @EnableExpiration annotation in docs
- Integrate Apache Geode and Jetty 11 HOT 1
- Improve Logging configuration in the Starter
- @LocatorApplication does not work with @EnableSecurity HOT 5
- PARTITION_PERSISTENT_OVERFLOW index slow HOT 6
- SBDG Fails in Docker HOT 10
- Gemfire Fails in AWS ECS HOT 8
- Add new BeanPostProcessor to register RegionConfigurers for explicitly declared Region beans
- Improve logging output for @EnableClusterAware functionality re:connection type HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot-data-geode.