hapi-fhir-jpaserver-starter
hapi-fhir-jpaserver-starter copied to clipboard
mvn verify fails on master
A number of integration tests failing for me. Not obvious what the cause is. Appears the CI build is passing because it only runs mvn package
, which does not trigger the integration tests.
[ERROR] Errors:
[ERROR] ElasticsearchLastNR4IT.testLastN » IllegalState Failed to load ApplicationCont...
[ERROR] ExampleServerDstu2IT.testCreateAndRead » IllegalState Failed to load Applicati...
[ERROR] ExampleServerDstu3IT.testCreateAndRead » IllegalState Failed to load Applicati...
[ERROR] ExampleServerDstu3IT.testWebsocketSubscription » IllegalState Failed to load A...
[ERROR] ExampleServerR4IT.testBatchPutWithIdenticalTags » IllegalState Failed to load ...
[ERROR] ExampleServerR4IT.testCreateAndRead » IllegalState Failed to load ApplicationC...
[ERROR] ExampleServerR4IT.testWebsocketSubscription » IllegalState Failed to load Appl...
[ERROR] ExampleServerR5IT.testCreateAndRead » IllegalState Failed to load ApplicationC...
[ERROR] ExampleServerR5IT.testWebsocketSubscription » IllegalState Failed to load Appl...
[ERROR] MultitenantServerR4IT.testCreateAndReadInTenantA » IllegalState Failed to load...
[ERROR] MultitenantServerR4IT.testCreateAndReadInTenantB » IllegalState Failed to load...
The failures are all caused by the following error
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Jetty web server
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Jetty web server
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hapiServletRegistration' defined in ca.uhn.fhir.jpa.starter.Application: Unsatisfied dependency expressed through method 'hapiServletRegistration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restfulServer' defined in class path resource [ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.class]: Unsatisfied dependency expressed through method 'restfulServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySystemDaoR4': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restfulServer' defined in class path resource [ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.class]: Unsatisfied dependency expressed through method 'restfulServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySystemDaoR4': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySystemDaoR4': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
Caused by: java.lang.IllegalStateException: Unable to detect database type
I'm not in a spot to validate at the moment, but try adding the "-Pboot" flag.
@XcrigX Thanks. Same issue when running as suggested
mvn verify -Pboot
The tests were passing as of a95c40d. It seems they began failing when https://github.com/hapifhir/hapi-fhir-jpaserver-starter/pull/444 was merged.
Restoring the H2 datasource in src/main/resource/application.yaml
resolves the issue for me. Per this thread, I think the error I observed occurs when Hibernate cannot connect to postgres as configured. During the integration test there appears to be no external PG DB for the application to connect to. Previously, the integration tests used H2, so no external DB was needed.
Seems like there are a number of options to address - add PG container in test using testcontainers, use H2 for test, etc.
But also, it is counterintuitive to me (newcomer to this project) that src/main/resources/application.yaml
influences the app in test given the existence of src/test/resources/application-integrationtest.yaml
. What is the intended behavior?
Agree with your assessment @laneb - Looks to me like it would be better of the #444 commit overrode the datasource as environment variables in the Docker container rather than altering the defalt classpasth application.yaml file to point to Postgres. Probably just an oversite here. @jkiddo ? Related, do the github auto-checks only run unit tests and not integration tests? They would have caught this if they ran the verify phase.
@XcrigX - yes, that PR went a bit too far. I'll roll it back to default to H2
Thanks @jkiddo.
@XcrigX That's correct - the CI workflow runs mvn package
, which does not include unit tests. I'd suggest swapping that for mvn verify
to include integration tests. Happy to PR it myself unless there's a reason not to do this.
Please provide a PR then