Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot 2.6: Fix the circular reference issues allow-circular-references: true #944

Closed
Jeeppler opened this issue Jan 14, 2022 · 3 comments · Fixed by #983
Closed

SpringBoot 2.6: Fix the circular reference issues allow-circular-references: true #944

Jeeppler opened this issue Jan 14, 2022 · 3 comments · Fixed by #983

Comments

@Jeeppler
Copy link
Member

Jeeppler commented Jan 14, 2022

Problem

SpringBoot 2.6 prohibits circular references between beans by default: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#circular-references-prohibited-by-default. The workaround is to set allow-circular-references: true in the sechub-server/src/main/resources/application.yml. The workaround works, but is far from ideal.

This problem became visible while working on #691.

Details

On Spring Boot Application Start of sechub-server (it does not happen at PDSstart) we have following output inside console:

2022-02-09 10:36:33.445 ERROR 27969 --- [           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:

   domainMessageService defined in file [/home/albert/develop/projects/sechub/sechub-review-open-source/sechub-shared-kernel/bin/main/com/daimler/sechub/sharedkernel/messaging/DomainMessageService.class]
      ↓
   scanMessageHandler (field com.daimler.sechub.domain.scan.project.ScanProjectConfigAccessLevelService com.daimler.sechub.domain.scan.ScanMessageHandler.projectAccessLevelService)
┌─────┐
|  scanProjectConfigAccessLevelService (field com.daimler.sechub.domain.scan.project.ScanProjectConfigService com.daimler.sechub.domain.scan.project.ScanProjectConfigAccessLevelService.scanProjectConfigService)
↑     ↓
|  scanProjectConfigService (field com.daimler.sechub.domain.scan.ScanAssertService com.daimler.sechub.domain.scan.project.ScanProjectConfigService.scanAssertService)
↑     ↓
|  scanAssertService (field com.daimler.sechub.domain.scan.project.ScanProjectConfigAccessLevelService com.daimler.sechub.domain.scan.ScanAssertService.accessLevelService)
└─────┘


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.


Solution

Fix the circular references issue and remove the allow-circular-references: true in sechub-server/src/main/resources/application.yml.

@Jeeppler Jeeppler changed the title Fix the circular reference issues allow-circular-references: true SpringBoot 2.6: Fix the circular reference issues allow-circular-references: true Jan 14, 2022
@Jeeppler Jeeppler added this to the Server 0.29.0 milestone Jan 14, 2022
@Vivek-Prajapatii
Copy link
Contributor

may i work on it?
but need a detailed explaination as i dont know anything about spring and SpringBoot

@Jeeppler
Copy link
Member Author

Jeeppler commented Jan 19, 2022

Hello @Vivek-Prajapatii ,

the problem has to do with some tests. This is a problem which should be looked at by @de-jcup as it requires an in-depth knowledge of both SecHub and the SpringFramework.

@Vivek-Prajapatii
Copy link
Contributor

okhay no problem

de-jcup added a commit that referenced this issue Feb 9, 2022
- some assert services where used by caller side but reuse them as well
- so it was not clear for the framework which one would be
  initialized first.
- To avoid this, the assert services get the callers injected lazy, so
  only necessary at runtime when instances are already created
de-jcup added a commit that referenced this issue Feb 9, 2022
…eferences

Avoid circular reference problem on container start, fixes #944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants