5

I'm trying to upload a resource to HAPI. It's based on the resource type basic, and I have created a custom profile(and extensions) for the concept I'm trying to capture. I have uploaded those StructureDefinitions to the server I'm using (hosted on local host), but I am not yet validating this upload against it (still trying to test that the format I've been using for my xml is correct).

I've uploaded the following bundle (there are many more records in the actual bundle, I've just edited it down for clarity):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Bundle>
  <meta>
    <lastUpdated value="2016-10-28T16:29:43Z"/>
  </meta>
  <type value="transaction"/>
  <entry>
    <resource>
      <Basic>
        <text>
          <status value="generated"/>
          <div/>
        </text>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/DateID">
          <valueDate value="2016-11-01"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/SptSolution">
          <valueCoding value="SptSolution.CatFurSPTSoln"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/MethodOfFollowUp">
          <valueCoding value="FollowUpMethod.ClinicVisit"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/SPTDefinition">
          <valueString value="A positive skin prick test result was defined as a mean wheal diameter of 3mm greater than that of the negative control"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/SubjectNo">
          <valueString value="4320"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/AIW">
          <valueInteger value="58"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/FollowUp">
          <valueCoding value="FollowUp.MSAge1Y"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/Subject">
          <valueCoding value="Person.StudySubject"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/VariableLabel">
          <valueString value="Child sensitised to cat (age 1 spt)"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/SPTDataType">
          <valueCoding value="SkinPrickTestData.SPTResult"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/DataSource">
          <valueCoding value="DataSource.ClinicalMeasurement"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/ClinicalType">
          <valueCoding value="ClinicalMeasurement.SkinPrickTest"/>
        </extension>
        <extension url="http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2/StructureDefinition/DataSPTResult">
          <valueCoding value="TestResult.Negative"/>
        </extension>
      </Basic>
    </resource>
    <request>
      <method value="POST"/>
      <url value="Basic"/>
    </request>
  </entry>
</Bundle>

Which seems to have uploaded correctly, since I get the response:

<Bundle xmlns="http://hl7.org/fhir">
    <id value="5d8d77ed-762f-4a64-b6b1-7a3aeacac52f"/>
    <type value="transaction-response"/>
    <link>
        <relation value="self"/>
        <url value="http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu2"/>
    </link>
    <entry>
        <response>
            <status value="201 Created"/>
            <location value="Basic/1107/_history/1"/>
            <etag value="1"/>
            <lastModified value="2016-11-01T15:09:56.264+00:00"/>
        </response>
    </entry>
</Bundle>

However when I try to access this via the URL:

{{URL}}/Basic/1107

I get the following response:

{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">error</td><td>[]</td><td><pre>Failed to call access method</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
  },
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "Failed to call access method"
    }
  ]
}

Any idea what could be causing this issue? It works fine when I upload patients and try to pull them back, But trying it for basic does not seem to work.

Andy
  • 3,228
  • 8
  • 40
  • 65

2 Answers2

7

This is indeed a bug in HAPI. I'm about to check in a fix.

FWIW you can work around it by not including the empty <div/> tag in your narrative (or adding content to the div).

James Agnew
  • 701
  • 4
  • 3
2

Seems to be a bug, i can reproduce this behavior on our server as well:

Here is the full stacktrace:

ca.uhn.fhir.parser.DataFormatException: String does not appear to be valid XML/XHTML (error is "Unexpected character ' ' (code 32) expected '>'
 at [row,col {unknown-source}]: [1,6]"): <div/ xmlns="http://www.w3.org/1999/xhtml">
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:127)
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:41)
    at ca.uhn.fhir.model.api.BasePrimitive.setValueAsString(BasePrimitive.java:112)
    at ca.uhn.fhir.model.primitive.XhtmlDt.setValueAsString(XhtmlDt.java:152)
    at ca.uhn.fhir.parser.ParserState$XhtmlState.attributeValue(ParserState.java:2592)
    at ca.uhn.fhir.parser.ParserState.attributeValue(ParserState.java:117)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1346)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1271)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1334)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1271)
    at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:226)
    at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:641)
    at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:689)
    at ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.toResource(BaseHapiFhirDao.java:1024)
    at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.read(BaseHapiFhirResourceDao.java:768)
    at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy81.read(Unknown Source)
    at ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider.read(BaseJpaResourceProvider.java:125)
    at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at ca.uhn.fhir.rest.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:271)
    at ca.uhn.fhir.rest.method.ReadMethodBinding.invokeServer(ReadMethodBinding.java:221)
    at ca.uhn.fhir.rest.method.ReadMethodBinding.invokeServer(ReadMethodBinding.java:61)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:306)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:257)
    at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:659)
    at ca.uhn.fhir.rest.server.RestfulServer.doGet(RestfulServer.java:1203)
    at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1179)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at de.gecko.hapi.filter.CorsFilter.doFilter(CorsFilter.java:44)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) expected '>'
 at [row,col {unknown-source}]: [1,6]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647)
    at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3002)
    at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2963)
    at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2100)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2080)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
    at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:114)
    ... 62 common frames omitted
2016-11-02 15:03:46.679 [http-bio-8080-exec-26] ERROR c.u.f.r.s.i.ExceptionHandlingInterceptor [ExceptionHandlingInterceptor.java:126] Failure during REST processing
ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Failed to call access method
    at ca.uhn.fhir.rest.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:276)
    at ca.uhn.fhir.rest.method.ReadMethodBinding.invokeServer(ReadMethodBinding.java:221)
    at ca.uhn.fhir.rest.method.ReadMethodBinding.invokeServer(ReadMethodBinding.java:61)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:306)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:257)
    at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:659)
    at ca.uhn.fhir.rest.server.RestfulServer.doGet(RestfulServer.java:1203)
    at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1179)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at de.gecko.hapi.filter.CorsFilter.doFilter(CorsFilter.java:44)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at ca.uhn.fhir.rest.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:271)
    ... 31 common frames omitted
Caused by: ca.uhn.fhir.parser.DataFormatException: Failed to parse database resource[class ca.uhn.fhir.model.dstu2.resource.Basic/1375 (pid 1375, version DSTU2): String does not appear to be valid XML/XHTML (error is "Unexpected character ' ' (code 32) expected '>'
 at [row,col {unknown-source}]: [1,6]"): <div/ xmlns="http://www.w3.org/1999/xhtml">
    at ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.toResource(BaseHapiFhirDao.java:1039)
    at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.read(BaseHapiFhirResourceDao.java:768)
    at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy81.read(Unknown Source)
    at ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider.read(BaseJpaResourceProvider.java:125)
    ... 35 common frames omitted
Caused by: ca.uhn.fhir.parser.DataFormatException: String does not appear to be valid XML/XHTML (error is "Unexpected character ' ' (code 32) expected '>'
 at [row,col {unknown-source}]: [1,6]"): <div/ xmlns="http://www.w3.org/1999/xhtml">
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:127)
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:41)
    at ca.uhn.fhir.model.api.BasePrimitive.setValueAsString(BasePrimitive.java:112)
    at ca.uhn.fhir.model.primitive.XhtmlDt.setValueAsString(XhtmlDt.java:152)
    at ca.uhn.fhir.parser.ParserState$XhtmlState.attributeValue(ParserState.java:2592)
    at ca.uhn.fhir.parser.ParserState.attributeValue(ParserState.java:117)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1346)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1271)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1334)
    at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1271)
    at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:226)
    at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:641)
    at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:689)
    at ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.toResource(BaseHapiFhirDao.java:1024)
    ... 49 common frames omitted
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) expected '>'
 at [row,col {unknown-source}]: [1,6]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647)
    at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3002)
    at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2963)
    at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2100)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2080)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
    at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
    at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:114)
    ... 62 common frames omitted

I posted this problem to the FHIR Chat: https://chat.fhir.org/#narrow/stream/hapi/subject/Basic.20Resource.20bug

Patrick Werner
  • 1,106
  • 9
  • 24
  • Have you found any work around to this? I'm only just getting started with FHIR so perhaps I'm not returning resources in the typical manner, but it seems pretty mission critical that it can't return resources by id? – Andy Nov 03 '16 at 11:09