ehrbase/openEHR_SDK

NullPointerException occurs while uploading a template to Better server

Closed this issue · 2 comments

Configuration information

openEHR_SDK: 30e3c81
Better: 3.0.19

ehrbase/fhir-bridge#514

Steps to reproduce

        OpenEhrClientConfig config = new OpenEhrClientConfig(new URI("http://localhost:8081/"));
        OpenEhrClient client = new DefaultRestClient(config);
        client.templateEndpoint().ensureExistence("Körpergröße");

Actual result

The last line of the following method throw a java.lang.NullPointerException

    String upload(OPERATIONALTEMPLATE operationaltemplate) {
        URI uri = defaultRestClient.getConfig().getBaseUri().resolve(DEFINITION_TEMPLATE_ADL_1_4_PATH);
        XmlOptions opts = new XmlOptions();
        opts.setSaveSyntheticDocumentElement(new QName("http://schemas.openehr.org/v1", "template"));

        HttpResponse response =
                defaultRestClient.internalPost(uri, null, operationaltemplate.xmlText(opts), ContentType.APPLICATION_XML, ContentType.APPLICATION_XML.getMimeType());

        Header etag = response.getFirstHeader(HttpHeaders.ETAG);
        return etag.getValue().replace("\"", "");
    }
java.lang.NullPointerException: null
at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestTemplateEndpoint.upload(DefaultRestTemplateEndpoint.java:136) ~[client-10cce9b.jar!/:na]
at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestTemplateEndpoint.ensureExistence(DefaultRestTemplateEndpoint.java:114) ~[client-10cce9b.jar!/:na]

Expected result (Acceptance Criteria)

According to the specification, ETag header is optional:

An ETag response header MAY be present and contain the unique identifier of the operational template instance

As a result, the method should also return an Optional<String>

Definition of Done

  • The defect is checked by an unit or an integration test (Robot)
  • Merge Request approved
  • Unit tests passed
  • Build without errors
  • Release notes prepared
  • No additional runtime warnings

Following...

A work around for the mean-time for this in-case anyone is experiencing the same:

  1. Make sure you have all the templates required at the initial start.
  2. Else, at every " Error creating bean with name...." error, run "java -jar fhir-bridge-x.x.x-SNAPSHOT.jar" repeat sequence until all templates preloaded in FHIR Bridge are loaded in the repository.
    When all templates are loaded in the repository, then FHIR Bridge will start successfully.