FHIR Chat · DSTU3 context server fails to initialize · implementers

Stream: implementers

Topic: DSTU3 context server fails to initialize


view this post on Zulip Slava Chabanov (Nov 29 2017 at 00:13):

I started playing with dstu2 models and then realized we need to be on sdtu3. I switched my Patient Resource to use org.hl7.fhir.dstu3.model.Patient

Here is how my servlet looks:

public class FhirApplication extends RestfulServer {

private static final long serialVersionUID = 1L;

/**
 * The initialize method is automatically called when the servlet is
 * starting up, so it can be used to configure the servlet to define
 * resource providers, or set up configuration, interceptors, etc.
 */
@Override
protected void initialize() throws ServletException {
    // Create a context, set the error handler and instruct
      // the server to use it
      FhirContext ctx = FhirContext.forDstu3();
      ctx.setParserErrorHandler(new StrictErrorHandler());
      setFhirContext(ctx);
    /*
     * The servlet defines any number of resource providers, and configures
     * itself to use them by calling setResourceProviders()
     */

    List<IServerInterceptor> interceptors = new ArrayList<IServerInterceptor>();
    BasicSecurityInterceptor bsi = new BasicSecurityInterceptor();
    interceptors.add(bsi);
    setInterceptors(interceptors);
    List<IResourceProvider> resourceProviders = new ArrayList<IResourceProvider>();
    resourceProviders.add(new PatientResourceProvider());
    setResourceProviders(resourceProviders);
}

}

My PatientResouceProvider.java implements ca.uhn.fhir.rest.server.IResourceProvider.
What confused me a bit is that [here][1] it says that base for all resources is org.hl7.fhir.instance.model.api.IBaseResource

And when I try to run the server, I get this error:

 Nested in javax.servlet.ServletException: Failed to initialize FHIR Restful server:
ca.uhn.fhir.context.ConfigurationException: Field 'div' in type 'org.hl7.fhir.dstu3.model.Narrative' is not a valid child type: class org.hl7.fhir.utilities.xhtml.XhtmlNode

Has anyone seen this error beofre? I haven't found anything online.
Thank you!

[1]: http://hapifhir.io/doc_dstu2.html#Using_the_DSTU3_Structures_in_Your_Application "here"


Last updated: Apr 12 2022 at 19:14 UTC