hapi-fhir-jpaserver-starter icon indicating copy to clipboard operation
hapi-fhir-jpaserver-starter copied to clipboard

R5 - APPLICATION FAILED TO START

Open porofoskini opened this issue 1 year ago • 11 comments

Hello to everybody! With the last release 7.0.0 , the server doesn't work with FHIR_VERSION = R5

hapi-fhir-jpaserver-start | 2024-02-29 15:12:54.289 [background-preinit] INFO o.h.validator.internal.util.Version [Version.java:21] HV000001: Hibernate Validator 8.0.0.Final hapi-fhir-jpaserver-start | 2024-02-29 15:12:54.415 [main] INFO ca.uhn.fhir.jpa.starter.Application [StartupInfoLogger.java:50] Starting Application using Java 17.0.10 with PID 1 (/app/main.war started by nonroot in /app) hapi-fhir-jpaserver-start | 2024-02-29 15:12:54.417 [main] INFO ca.uhn.fhir.jpa.starter.Application [SpringApplication.java:653] No active profile set, falling back to 1 default profile: "default" hapi-fhir-jpaserver-start | 2024-02-29 15:12:55.983 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java:139] Bootstrapping Spring Data JPA repositories in DEFAULT mode. hapi-fhir-jpaserver-start | 2024-02-29 15:12:56.332 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java:208] Finished Spring Data repository scanning in 334 ms. Found 53 JPA repository interfaces. hapi-fhir-jpaserver-start | 2024-02-29 15:12:56.359 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [AbstractApplicationContext.java:632] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'subscriptionQueryValidator' defined in ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig; factoryMethodName=subscriptionQueryValidator; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig] for bean 'subscriptionQueryValidator' since there is already [Root bean: class [null]; scope=; abstract=false; lazyInit=true; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=ca.uhn.fhir.jpa.topic.SubscriptionTopicConfig; factoryMethodName=subscriptionQueryValidator; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.class]] bound. hapi-fhir-jpaserver-start | 2024-02-29 15:12:56.385 [main] INFO o.s.b.a.l.ConditionEvaluationReportLogger [ConditionEvaluationReportLogger.java:82] hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. hapi-fhir-jpaserver-start | 2024-02-29 15:12:56.438 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter [LoggingFailureAnalysisReporter.java:40] hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | *************************** hapi-fhir-jpaserver-start | APPLICATION FAILED TO START hapi-fhir-jpaserver-start | *************************** hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | Description: hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | The bean 'subscriptionQueryValidator', defined in ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig, could not be registered. A bean with that name has already been defined in class path resource [ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.class] and overriding is disabled. hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | Action: hapi-fhir-jpaserver-start | hapi-fhir-jpaserver-start | Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

porofoskini avatar Feb 29 '24 15:02 porofoskini

I noticed the R4 IT test has bean overriding turned on: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java#L73

I assume this would "fix" your issue, but I'm not aware of why there is a clash or if it's a problem.

edit to add: There is a comment above the linked line explaining why bean overriding was turned on (for MDM).

XcrigX avatar Feb 29 '24 20:02 XcrigX

When using fhir R5 the bean subscriptionQueryValidator is loaded twice, because it's defined in both these classes:

https://github.com/hapifhir/hapi-fhir/blob/4570c28cb63c6b8ba74d6c15ef36c51e6947613c/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/config/SubscriptionSubmitterConfig.java#L57 https://github.com/hapifhir/hapi-fhir/blob/4570c28cb63c6b8ba74d6c15ef36c51e6947613c/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.java#L79

The second class is not annotated but it's imported explicitly in FhirServerConfigR5 and FhirServerConfigR4B, so even if the bean is lazy (not sure it would help) there is a clash. Maybe it's a random loading order issue.

stmsat avatar Mar 06 '24 10:03 stmsat

I dont think lazy solves anything here, IRC. Its defined twice and thats the root cause.

jkiddo avatar Mar 06 '24 18:03 jkiddo

still seeing this with latest release:

	... 23 common frames omitted
Caused by: jakarta.servlet.ServletException: HAPI-0297: Failed to initialize FHIR Restful server: HAPI-0288: Failure scanning class ImplementationGuideR5OperationProvider: HAPI-1731: This context is for FHIR version "R5" but the class "org.hl7.fhir.r4.model.Parameters" is for version "R4"
	at ca.uhn.fhir.rest.server.RestfulServer.init(RestfulServer.java:1444)
	at jakarta.servlet.GenericServlet.init(GenericServlet.java:143)
	at jakarta.servlet.http.HttpServlet.init(HttpServlet.java:121)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:944)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:808)
	at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbeddedContext.java:84)
	... 39 common frames omitted
Caused by: ca.uhn.fhir.context.ConfigurationException: HAPI-0288: Failure scanning class ImplementationGuideR5OperationProvider: HAPI-1731: This context is for FHIR version "R5" but the class "org.hl7.fhir.r4.model.Parameters" is for version "R4"
	at ca.uhn.fhir.rest.server.RestfulServer.findResourceMethods(RestfulServer.java:463)
	at ca.uhn.fhir.rest.server.RestfulServer.registerProviders(RestfulServer.java:1794)
	at ca.uhn.fhir.rest.server.RestfulServer.init(RestfulServer.java:1409)
	... 44 common frames omitted
Caused by: ca.uhn.fhir.context.ConfigurationException: HAPI-1731: This context is for FHIR version "R5" but the class "org.hl7.fhir.r4.model.Parameters" is for version "R4"

joofio avatar Mar 07 '24 09:03 joofio

Not fixed yet - short term fix is spring.main.allow-bean-definition-overriding=true

jkiddo avatar Mar 07 '24 10:03 jkiddo

whats your config?

jkiddo avatar Mar 07 '24 10:03 jkiddo

still seeing this with latest release:

Caused by: ca.uhn.fhir.context.ConfigurationException: HAPI-1731: This context is for FHIR version "R5" but the class "org.hl7.fhir.r4.model.Parameters" is for version "R4"

This should be fixed in the last commit (for those who have R5 and ig_runtime_upload_enabled=true).

stmsat avatar Mar 07 '24 10:03 stmsat

whats your config?

R5 and ig_runtime_upload_enabled=true, which i take has issues from @stmsat comment...

EDIT: tried with ig_runtime_upload_enabled=false and starts ok!

joofio avatar Mar 07 '24 10:03 joofio

So that last change wasn't included: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/compare/image/v7.0.2...master

You'll need a new release for that

jkiddo avatar Mar 07 '24 10:03 jkiddo

If this one (https://github.com/hapifhir/hapi-fhir-jpaserver-starter/actions/runs/8186830878) goes through then there'll be a new version shortly

jkiddo avatar Mar 07 '24 10:03 jkiddo

7.0.3 fixed @joofio 's issue. spring.main.allow-bean-definition-overriding=true will be needed for the time being.

jkiddo avatar Mar 07 '24 11:03 jkiddo

Closed with workaround

jkiddo avatar Apr 16 '24 17:04 jkiddo