[BUG]Using Cosmos Auditing with latest spring boot version 2.6.1 throws Circular dependency errors #25755
Labels
azure-spring
All azure-spring related issues
azure-spring-cosmos
Spring cosmos related issues.
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
dependency-issue
Issue that is caused by dependency conflicts
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone
Describe the bug
In order to resolve some security vulnerabilities from spring, we have upgraded to latest spring boot version 2.6.1 and we saw errors during application context initialization reporting circular dependencies between cosmosClient and CosmosAuditingHandler.
Exception or Stack Trace
Add the exception log and stack trace if available
2021-11-30 12:02:46.010 INFO 2764 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6148 ms
2021-11-30 12:02:46.897 WARN 2764 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cosmosHealthIndicatorConfig': Unsatisfied dependency expressed through field 'cosmosClient'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cosmosClientConfig': Unsatisfied dependency expressed through field 'cosmosAuditingHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cosmosAuditingHandler': Cannot create inner bean '(inner bean)#3d1cfad4' of type [com.azure.spring.data.cosmos.core.mapping.CosmosAuditingRegistrar$CosmosMappingContextLookup] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#3d1cfad4': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'cosmosClientConfig': Requested bean is currently in creation: Is there an unresolvable circular reference?
2021-11-30 12:02:46.908 INFO 2764 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-11-30 12:02:46.971 INFO 2764 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-30 12:02:47.107 ERROR 2764 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
The dependencies of some of the beans in the application context form a cycle:
cosmosHealthIndicatorConfig (field private com.azure.cosmos.CosmosAsyncClient com.nuance.powershare.messaging.config.health.CosmosHealthIndicatorConfig.cosmosClient)
┌─────┐
| cosmosClientConfig (field private org.springframework.data.auditing.IsNewAwareAuditingHandler com.azure.spring.data.cosmos.config.AbstractCosmosConfiguration.cosmosAuditingHandler)
↑ ↓
| cosmosAuditingHandler
↑ ↓
| (inner bean)#3d1cfad4
└─────┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
To Reproduce
Steps to reproduce the behavior:
Using "@EnableCosmosAuditing" annotation on the AppConfiguration has circular dependencies and the latest spring boot doesn't allow that.
Code Snippet
Add the code snippet that causes the issue.
Here is our configuration class code:
@configuration
@EnableConfigurationProperties(CosmosProperties.class)
@EnableCosmosRepositories(basePackages = "com.nuance.powershare.messaging.repository.cosmos")
@EnableCosmosAuditing
public class CosmosClientConfig extends AbstractCosmosConfiguration {
}
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
If you suspect a dependency version mismatch (e.g. you see
NoClassDefFoundError
,NoSuchMethodError
or similar), please providemvn dependency:tree -Dverbose
)Additional context
Add any other context about the problem here.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: