hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
1.99k stars 1.31k forks source link

Upgrading from 6.6.2 to 6.8.0 breaks server build/test #5251

Open brsolomon-deloitte opened 1 year ago

brsolomon-deloitte commented 1 year ago

Upgrading from HAPI FHIR 6.6.2 to 6.8.0 in pom.xml, with no other changes, breaks our FHIR server tests and install.

Current, using HAPI FHIR 6.6.2:

$ mvn clean test

...

[INFO] Results:
[INFO]
[INFO] Tests run: 21, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

Upgrade HAPI FHIR dependencies:

$ git --no-pager diff
diff --git a/pom.xml b/pom.xml
index 1e664ea..762d596 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
     <maven.compiler.source>17</maven.compiler.source>
     <maven.compiler.target>17</maven.compiler.target>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <hapifhir_version>6.6.2</hapifhir_version>
+    <hapifhir_version>6.8.0</hapifhir_version>
     <elasticsearch_client_version>6.8.23</elasticsearch_client_version>
     <maven_checkstyle_version>3.3.0</maven_checkstyle_version>
     <checkstyle_version>10.12.2</checkstyle_version>

$ grep -F fhir pom.xml
  <artifactId>fhir-server</artifactId>
    <hapifhir_version>6.8.0</hapifhir_version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-base</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-server</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-validation</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-server-openapi</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-structures-r5</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-validation-resources-r5</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-testpage-overlay</artifactId>
      <version>${hapifhir_version}</version>
      <groupId>ca.uhn.hapi.fhir</groupId>
      <artifactId>hapi-fhir-testpage-overlay</artifactId>
      <version>${hapifhir_version}</version>

After the change: mvn clean test with full output here:

https://gist.github.com/brsolomon-deloitte/37ecf55049587d04d3a9d07020701234

Short version:

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

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (the profiles test are currently active).

2023-08-28 11:15:50.968 ERROR 58657 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@45292ec1] to prepare test instance [REDACTED.RestfulServletTests@57ab4b33]

java.lang.IllegalStateException: Failed to load ApplicationContext

...

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.467 s <<< FAILURE! - in REDACTED.RestfulServletTests
[ERROR] REDACTED.RestfulServletTests  Time elapsed: 2.466 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Dbcp2.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.commons.dbcp2.BasicDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Dbcp2.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.commons.dbcp2.BasicDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Dbcp2.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.commons.dbcp2.BasicDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.commons.dbcp2.BasicDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   RestfulServletTests » IllegalState Failed to load ApplicationContext
[ERROR]   ServerApplicationTests.contextLoads » IllegalState Failed to load ApplicationC...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.988 s
[INFO] Finished at: 2023-08-28T11:15:51-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project fhir-server: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/REDACTED/fhir-server/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Environment (please complete the following information):

brsolomon-deloitte commented 1 year ago

For awareness, we are wrapping our HAPI FHIR restful servlet in a Spring app. We've had no issue with this using HAPI FHIR 6.6.2.

package redacted.redacted.redacted.redacted;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
 *  ServerApplication wraps the HAPI FHIR RestfulServer into a Spring Boot application.
 */

@ServletComponentScan("redacted.redacted.redacted.redacted")
@SpringBootApplication
public class ServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }
}
brsolomon-deloitte commented 1 year ago

This breakage went away when we removed ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay. My guess is that is due to the recent inclusion of ca.uhn.hapi.fhir:hapi-fhir-jpaserver-hfql as a dependency of ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay. However, that isn't exactly an acceptable workaround for us since we'd like to use the testpage-overlay with our plain server implementation.