LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects

Home Page:https://linuxforhealth.github.io/FHIR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FHIRPersistenceDBConnectException: Failure acquiring connection for datasource ( Caused by: ERROR XJ004: Database 'derby/fhirDB' not found. )

alexsapps opened this issue · comments

I'm trying to get the health check endpoint to pass after installing from ZIP on Windows. Here's what I did:

Expand-Archive -Path $env:USERPROFILE\Downloads\fhir-install-5.1.0.zip .\fhir-server-5.1.0
.\fhir-server-5.1.0\fhir-server-dist\install.bat
fhir-server-5.1.0\liberty-runtime\wlp\bin\server.bat start

The server starts successfully, but when I hit the health check (https://fhiruser:change-password@localhost:9443/fhir-server/api/v4/$healthcheck) I get the error:

<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="c0-a8-56-8c-75a511c8-75cd-4bbe-a98c-c76ef389e41d"/>
<issue>
<severity value="fatal"/>
<code value="exception"/>
<details>
<text value="FHIRPersistenceDBConnectException: Failure acquiring connection for datasource"/>
</details>
</issue>
</OperationOutcome>

In the log file fhir-server-5.1.0\liberty-runtime\wlp\usr\servers\defaultServer\logs\messages.log ( messages.log
) I see the cause:

java.sql.SQLException: Database 'derby/fhirDB' not found. DSRA0010E: SQL State = XJ004, Error Code = 40,000

If any DB specific steps are required, I did not find it to be clear from the guide. The guide says in steps 7 - 9 that Derby comes pre-configured so it seems no action is required and the database should just work.

Agree this line is a bit misleading:

By default, the FHIR server is installed with the JDBC persistence layer configured to use an Embedded Derby database.

What it means is that our configurable persistence layer implementation defaults to derby.
But derby isn't bootstrapped during application launch...its a separate action to create the database and deploy the schema, which is what we try to cover in the guide.
We make that pretty simple for the container version, but its less simple for those using just the zip installer.
Lets take a shot at improving the docs on this front.

related idea: support some optional flag on the install script which will create the derby db and provision our schema to it

That would be great to have the docs clarified or add the option in the install script.

In the meantime, if the guide already covers the separate action of creating a Derby database and deploying the schema, could you point me to that section in the docs so I can try it out? Any example commands would be especially helpful. No worries if not; In the meantime I am testing with the container version.

step 8 just says:

When using the ibmcom/ibm-fhir-server docker image, set the BOOTSTRAP_DB environment variable to true in order to bootstrap this database. For any other configuration, use the fhir-persistence-schema module to create and deploy the database schema.

Actual info on using fhir-persistence-schema is in that module's README: https://github.com/LinuxForHealth/FHIR/tree/main/fhir-persistence-schema

We link to that from our release notes but not from this user's guide for some reason... we really should.

The key is to create the database in the same location that your datasource is looking for it.
By default, that datasource is defined at wlp/usr/servers/defaultServer/configDropins/defaults/datasource.xml
Configuring the datasource is documented at https://linuxforhealth.github.io/FHIR/guides/FHIRServerUsersGuide#33-persistence-layer-configuration

Net: we spent some time trying to make it as simple as possible to get going with the container.
But with the zip installer its definitely a pain.