hapifhir / hapi-fhir-jpaserver-starter

Apache License 2.0
394 stars 1.05k forks source link

Error when running Docker with PostgreSQL #573

Closed neumartin closed 1 year ago

neumartin commented 1 year ago

Hi!

I have this docker-compose.yml

version: '3.7'
services:
  web:
    image: "hapiproject/hapi:latest"
    ports:
      - "8090:8080"
    volumes:
      - /home/martin/docker/hapi-fhir/config/application.yaml:/data/hapi/application.yaml
    environment:
      SPRING_CONFIG_LOCATION: 'file:///data/hapi/application.yaml'

And this application.yaml

spring:
  datasource:
    url: 'jdbc:postgresql://172.17.0.3:5432/hapi'
    username: postgres
    password: password
    driverClassName: org.postgresql.Driver

But when starts, I get this error:

hapi-fhir-web-1  | 
hapi-fhir-web-1  |   .   ____          _            __ _ _
hapi-fhir-web-1  |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
hapi-fhir-web-1  | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
hapi-fhir-web-1  |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
hapi-fhir-web-1  |   '  |____| .__|_| |_|_| |_\__, | / / / /
hapi-fhir-web-1  |  =========|_|==============|___/=/_/_/_/
hapi-fhir-web-1  | 
hapi-fhir-web-1  |  :: Spring Boot ::               (v2.7.11)
hapi-fhir-web-1  | 
hapi-fhir-web-1  | 
hapi-fhir-web-1  | 2023-08-02 01:01:14.344 [main] INFO  ca.uhn.fhir.jpa.starter.Application [StartupInfoLogger.java:55] Starting Application using Java 17.0.6 on f9256a81aeb1 with PID 1 (/app/main.war started by nonroot in /app)
hapi-fhir-web-1  | 2023-08-02 01:01:14.346 [background-preinit] INFO  o.h.validator.internal.util.Version [Version.java:21] HV000001: Hibernate Validator 6.1.5.Final
hapi-fhir-web-1  | 2023-08-02 01:01:14.348 [main] INFO  ca.uhn.fhir.jpa.starter.Application [SpringApplication.java:631] No active profile set, falling back to 1 default profile: "default"
hapi-fhir-web-1  | 2023-08-02 01:01:14.549 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [AbstractApplicationContext.java:591] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/app/main.war!/WEB-INF/classes!/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.class]; nested exception is java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because the return value of "org.springframework.core.env.Environment.getProperty(String)" is null
hapi-fhir-web-1  | 2023-08-02 01:01:14.866 [main] ERROR o.s.boot.SpringApplication [SpringApplication.java:821] Application run failed
hapi-fhir-web-1  | org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/app/main.war!/WEB-INF/classes!/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.class]; nested exception is java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because the return value of "org.springframework.core.env.Environment.getProperty(String)" is null
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:457)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:276)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:128)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:206)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:174)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
hapi-fhir-web-1  |      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
hapi-fhir-web-1  |      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
hapi-fhir-web-1  |      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:748)
hapi-fhir-web-1  |      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
hapi-fhir-web-1  |      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
hapi-fhir-web-1  |      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
hapi-fhir-web-1  |      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
hapi-fhir-web-1  |      at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
hapi-fhir-web-1  |      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
hapi-fhir-web-1  |      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
hapi-fhir-web-1  |      at ca.uhn.fhir.jpa.starter.Application.main(Application.java:44)
hapi-fhir-web-1  |      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
hapi-fhir-web-1  |      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
hapi-fhir-web-1  |      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
hapi-fhir-web-1  |      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
hapi-fhir-web-1  |      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
hapi-fhir-web-1  |      at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
hapi-fhir-web-1  |      at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
hapi-fhir-web-1  |      at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
hapi-fhir-web-1  | Caused by: java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because the return value of "org.springframework.core.env.Environment.getProperty(String)" is null
hapi-fhir-web-1  |      at ca.uhn.fhir.jpa.starter.annotations.OnDSTU2Condition.matches(OnDSTU2Condition.java:14)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:88)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:71)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isConditionMatch(ClassPathScanningCandidateComponentProvider.java:512)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:495)
hapi-fhir-web-1  |      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
hapi-fhir-web-1  |      ... 28 common frames omitted
hapi-fhir-web-1 exited with code 1
jkiddo commented 1 year ago

your application.yaml does not state what FHIR version should be used.

jkiddo commented 1 year ago

@neumartin did it fix your problem to state the FHIR version?

neumartin commented 1 year ago

@jkiddo, yes, I used the full application.yaml data, mine is:

#Adds the option to go to eg. http://localhost:8080/actuator/health for seeing the running configuration
#see https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints
management:
  endpoints:
    web:
      exposure:
        include: "health,prometheus"
spring:
  main:
    allow-circular-references: true
    #allow-bean-definition-overriding: true
  flyway:
    enabled: false
    check-location: false
    baselineOnMigrate: true
  datasource:
    url: 'jdbc:postgresql://172.27.0.2:5432/hapi'
    username: admin
    password: admin
    driverClassName: org.postgresql.Driver

    # database connection pool size
    hikari:
      maximum-pool-size: 10
  jpa:
    properties:
      hibernate.format_sql: false
      hibernate.show_sql: false

      #Hibernate dialect is automatically detected except Postgres and H2.
      #If using H2, then supply the value of ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect
      #If using postgres, then supply the value of ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
      hibernate.dialect: ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
  #      hibernate.hbm2ddl.auto: update
  #      hibernate.jdbc.batch_size: 20
  #      hibernate.cache.use_query_cache: false
  #      hibernate.cache.use_second_level_cache: false
  #      hibernate.cache.use_structured_entries: false
  #      hibernate.cache.use_minimal_puts: false

  ###    These settings will enable fulltext search with lucene or elastic
      hibernate.search.enabled: true
  ### lucene parameters
#      hibernate.search.backend.type: lucene
#      hibernate.search.backend.analysis.configurer: ca.uhn.fhir.jpa.search.HapiHSearchAnalysisConfigurers$HapiLuceneAnalysisConfigurer
#      hibernate.search.backend.directory.type: local-filesystem
#      hibernate.search.backend.directory.root: target/lucenefiles
#      hibernate.search.backend.lucene_version: lucene_current
  ### elastic parameters ===> see also elasticsearch section below <===
#      hibernate.search.backend.type: elasticsearch
#      hibernate.search.backend.analysis.configurer: ca.uhn.fhir.jpa.search.HapiHSearchAnalysisConfigurers$HapiElasticAnalysisConfigurer
hapi:
  fhir:

    ### This enables the swagger-ui at /fhir/swagger-ui/index.html as well as the /fhir/api-docs (see https://hapifhir.io/hapi-fhir/docs/server_plain/openapi.html)
    openapi_enabled: true
    ### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5
    fhir_version: R4
    ### This flag when enabled to true, will avail evaluate measure operations from CR Module.
    ### Flag is false by default, can be passed as command line argument to override.
    cr_enabled: false
    ### enable to use the ApacheProxyAddressStrategy which uses X-Forwarded-* headers
    ### to determine the FHIR server address
    #   use_apache_address_strategy: false
    ### forces the use of the https:// protocol for the returned server address.
    ### alternatively, it may be set using the X-Forwarded-Proto header.
    #   use_apache_address_strategy_https: false
    ### enables the server to host content like HTML, css, etc. under the url pattern of /static/**
    ### the deepest folder level will be used. E.g. - if you put file:/foo/bar/bazz as value then the files are resolved under /static/bazz/**
    #staticLocation: file:/foo/bar/bazz
    ### enable to set the Server URL
    #    server_address: http://hapi.fhir.org/baseR4
    #    defer_indexing_for_codesystems_of_size: 101
    #    install_transitive_ig_dependencies: true
    ### tells the server whether to attempt to load IG resources that are already present
    #    reload_existing_implementationGuides : false
    #    implementationguides:
    ###    example from registry (packages.fhir.org)
    #      swiss:
    #        name: swiss.mednet.fhir
    #        version: 0.8.0
    #      example not from registry
    #      ips_1_0_0:
    #        url: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz
    #        name: hl7.fhir.uv.ips
    #        version: 1.0.0
    #    supported_resource_types:
    #      - Patient
    #      - Observation
    ##################################################
    # Allowed Bundle Types for persistence (defaults are: COLLECTION,DOCUMENT,MESSAGE)
    ##################################################
    #    allowed_bundle_types: COLLECTION,DOCUMENT,MESSAGE,TRANSACTION,TRANSACTIONRESPONSE,BATCH,BATCHRESPONSE,HISTORY,SEARCHSET
    #    allow_cascading_deletes: true
    #    allow_contains_searches: true
    #    allow_external_references: true
    #    allow_multiple_delete: true
    #    allow_override_default_search_params: true
    #    auto_create_placeholder_reference_targets: false
    ### tells the server to automatically append the current version of the target resource to references at these paths
    #    auto_version_reference_at_paths: Device.patient, Device.location, Device.parent, DeviceMetric.parent, DeviceMetric.source, Observation.device, Observation.subject
    #    cr_enabled: true
    #    ips_enabled: false
    #    default_encoding: JSON
    #    default_pretty_print: true
    #    default_page_size: 20
    #    delete_expunge_enabled: true
    #    enable_repository_validating_interceptor: true
    #    enable_index_missing_fields: false
    #    enable_index_of_type: true
    #    enable_index_contained_resource: false
    ###  !!Extended Lucene/Elasticsearch Indexing is still a experimental feature, expect some features (e.g. _total=accurate) to not work as expected!!
    ###  more information here: https://hapifhir.io/hapi-fhir/docs/server_jpa/elastic.html
    advanced_lucene_indexing: false
    bulk_export_enabled: false
    bulk_import_enabled: false
    #    enforce_referential_integrity_on_delete: false
    # This is an experimental feature, and does not fully support _total and other FHIR features.
    #    enforce_referential_integrity_on_delete: false
    #    enforce_referential_integrity_on_write: false
    #    etag_support_enabled: true
    #    expunge_enabled: true
    #    client_id_strategy: ALPHANUMERIC
    #    fhirpath_interceptor_enabled: false
    #    filter_search_enabled: true
    #    graphql_enabled: true
    narrative_enabled: false
    #    mdm_enabled: true
    #    local_base_urls:
    #      - https://hapi.fhir.org/baseR4
    mdm_enabled: false
    #    partitioning:
    #      allow_references_across_partitions: false
    #      partitioning_include_in_search_hashes: false
    cors:
      allow_Credentials: true
      # These are allowed_origin patterns, see: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/cors/CorsConfiguration.html#setAllowedOriginPatterns-java.util.List-
      allowed_origin:
        - '*'

    # Search coordinator thread pool sizes
    search-coord-core-pool-size: 20
    search-coord-max-pool-size: 100
    search-coord-queue-capacity: 200

    # comma-separated package names, will be @ComponentScan'ed by Spring to allow for creating custom Spring beans
    #custom-bean-packages:

    # comma-separated list of fully qualified interceptor classes. 
    # classes listed here will be fetched from the Spring context when combined with 'custom-bean-packages', 
    # or will be instantiated via reflection using an no-arg contructor; then registered with the server  
    #custom-interceptor-classes:  

    # Threadpool size for BATCH'ed GETs in a bundle.
    #    bundle_batch_pool_size: 10
    #    bundle_batch_pool_max_size: 50

    #    logger:
    #      error_format: 'ERROR - ${requestVerb} ${requestUrl}'
    #      format: >-
    #        Path[${servletPath}] Source[${requestHeader.x-forwarded-for}]
    #        Operation[${operationType} ${operationName} ${idOrResourceName}]
    #        UA[${requestHeader.user-agent}] Params[${requestParameters}]
    #        ResponseEncoding[${responseEncodingNoDefault}]
    #      log_exceptions: true
    #      name: fhirtest.access
    #    max_binary_size: 104857600
    #    max_page_size: 200
    #    retain_cached_searches_mins: 60
    #    reuse_cached_search_results_millis: 60000
    tester:
      home:
        name: Local Tester
        server_address: 'http://localhost:8080/fhir'
        refuse_to_fetch_third_party_urls: false
        fhir_version: R4
      global:
        name: Global Tester
        server_address: "http://hapi.fhir.org/baseR4"
        refuse_to_fetch_third_party_urls: false
        fhir_version: R4
    #    validation:
    #      requests_enabled: true
    #      responses_enabled: true
    #    binary_storage_enabled: true
    inline_resource_storage_below_size: 4000
#    bulk_export_enabled: true
#    subscription:
#      resthook_enabled: true
#      websocket_enabled: false
#      email:
#        from: some@test.com
#        host: google.com
#        port:
#        username:
#        password:
#        auth:
#        startTlsEnable:
#        startTlsRequired:
#        quitWait:
#    lastn_enabled: true
#    store_resource_in_lucene_index_enabled: true
###  This is configuration for normalized quantity search level default is 0
###   0: NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED - default
###   1: NORMALIZED_QUANTITY_STORAGE_SUPPORTED
###   2: NORMALIZED_QUANTITY_SEARCH_SUPPORTED
#    normalized_quantity_search_level: 2
#elasticsearch:
#  debug:
#    pretty_print_json_log: false
#    refresh_after_write: false
#  enabled: false
#  password: SomePassword
#  required_index_status: YELLOW
#  rest_url: 'localhost:9200'
#  protocol: 'http'
#  schema_management_strategy: CREATE
#  username: SomeUsername
westernsalt commented 1 year ago

How could you fix that problem? I need your help :(;

neumartin commented 1 year ago

How could you fix that problem? I need your help :(;

Use the complete configuration file, like this: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/issues/573#issuecomment-1674742469