Circular bean dependency

549 views
Skip to first unread message

Sean McIlvenna

unread,
Jun 5, 2022, 10:54:03 PM6/5/22
to HAPI FHIR
I'm trying to upgrade my fork of hapi-fhir-jpaserver-starter to 5.7 (to start with).. I'm getting the following error:

```
"C:\Program Files\Java\jdk-17.0.3.1\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51804,suspend=y,server=n -javaagent:C:\Users\sean.mcilvenna\AppData\Local\JetBrains\IntelliJIdea2021.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath C:\Users\sean.mcilvenna\AppData\Local\Temp\classpath1516253816.jar ca.uhn.fhir.jpa.starter.Demo
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Connected to the target VM, address: '127.0.0.1:51804', transport: 'socket'
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.2)

2022-06-05 19:52:16.881 [background-preinit] INFO  o.h.validator.internal.util.Version [Version.java:21] HV000001: Hibernate Validator 6.1.5.Final
2022-06-05 19:52:16.890 [main] INFO  ca.uhn.fhir.jpa.starter.Demo [StartupInfoLogger.java:55] Starting Demo using Java 17.0.3.1 on CT5RXY2-mcilven with PID 50964 (E:\Code\sequoia-hapi\target\test-classes started by sean.mcilvenna in E:\Code\sequoia-hapi)
2022-06-05 19:52:16.891 [main] INFO  ca.uhn.fhir.jpa.starter.Demo [SpringApplication.java:639] The following profiles are active: r4
2022-06-05 19:52:17.823 [main] INFO  o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java:132] Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-06-05 19:52:18.011 [main] INFO  o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java:201] Finished Spring Data repository scanning in 174 ms. Found 51 JPA repository interfaces.
2022-06-05 19:52:19.278 [main] INFO  ca.uhn.fhir.util.VersionUtil [VersionUtil.java:84] HAPI FHIR version 5.7.0 - Rev 0f1a306b58
2022-06-05 19:52:19.284 [main] INFO  ca.uhn.fhir.context.FhirContext [FhirContext.java:208] Creating new FHIR context for FHIR version [R4]
2022-06-05 19:52:19.572 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [AbstractApplicationContext.java:591] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fhirServerConfigR4': Unsatisfied dependency expressed through field 'myDaoRegistry'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'fhirServerConfigR4': Requested bean is currently in creation: Is there an unresolvable circular reference?
2022-06-05 19:52:19.599 [main] INFO  o.s.b.a.l.ConditionEvaluationReportLoggingListener [ConditionEvaluationReportLoggingListener.java:136]

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-05 19:52:19.652 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter [LoggingFailureAnalysisReporter.java:40]

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

┌──->──┐
|  fhirServerConfigR4 (field private ca.uhn.fhir.jpa.api.dao.DaoRegistry ca.uhn.fhir.jpa.config.BaseConfig.myDaoRegistry)
└──<-──┘


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.

Disconnected from the target VM, address: '127.0.0.1:51804', transport: 'socket'

Process finished with exit code 1
```

Can anyone point me in the right direction? I've been staring at this, not figuring it out... Thanks in advance!

Sajith Jamal

unread,
Jun 8, 2022, 4:59:26 PM6/8/22
to HAPI FHIR
ran into this issue myself, I had to downgrade back to 5.6.1 instead

tagging into this thread in case a solution is posted

regards,
Sajith

Martin Grofčík

unread,
Oct 14, 2022, 6:50:09 AM10/14/22
to HAPI FHIR
I tried with re_6_2_0 and master branch.

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'entityManagerFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:355)

COuld somebody help?

Regards
Martin
Reply all
Reply to author
Forward
0 new messages