FHIR Chat · Interceptor-validation resource doesn't exist · implementers

Stream: implementers

Topic: Interceptor-validation resource doesn't exist


view this post on Zulip Jordi Cabré (Jul 29 2021 at 07:53):

Currently, we are trying to check if a practitioner already exists using @Interceptor annotation:

@Interceptor
public class MpiValidationInterceptor {

    private final IFhirResourceDao<Practitioner> myPractitionerDaoR4;

    @Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED)
    public void storagePrestorageResourceCreated(RequestDetails theRequestDetails, IBaseResource theResource) {
        if(theResource instanceof Practitioner) {
            this.validatePractitioner((Practitioner)theResource,getLocaleFromRequest(theRequestDetails));
        }
    }

    private void validatePractitioner(Practitioner practitioner) {
        SearchParameterMap paramMap = new SearchParameterMap();
        //Fill paramMap
        IBundleProvider provider = myPractitionerDaoR4.search(paramMap);
        List<IBaseResource> list = provider.getAllResources();
        for(IBaseResource resource:list) {
            //do validation
        }
    }
}

Nevertheless, we're getting this error message when this code is reached:

2021-07-29 09:50:30.610 ERROR 12037 --- [nio-8093-exec-1] c.u.f.r.s.i.ExceptionHandlingInterceptor : Failure during REST processing

ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Failed to call access method: ca.uhn.fhir.context.ConfigurationException: Attempt to request all resources from an asynchronous search result.  The SearchParameterMap for this search probably should have been synchronous.
    at ca.uhn.fhir.rest.server.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:272) ~[hapi-fhir-server-5.4.1.jar:na]
    at ca.uhn.fhir.rest.server.method.BaseOutcomeReturningMethodBinding.invokeServer(BaseOutcomeReturningMethodBinding.java:154) ~[hapi-fhir-server-5.4.1.jar:na]
    at ca.uhn.fhir.rest.server.method.CreateMethodBinding.invokeServer(CreateMethodBinding.java:41) ~[hapi-fhir-server-5.4.1.jar:na]
    at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:1146) ~[hapi-fhir-server-5.4.1.jar:na]
    at ca.uhn.fhir.rest.server.RestfulServer.doPost(RestfulServer.java:417) ~[hapi-fhir-server-5.4.1.jar:na]
    at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1855) ~[hapi-fhir-server-5.4.1.jar:na]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.41.jar:4.0.FR]

The outcome is:

{
    "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: ca.uhn.fhir.context.ConfigurationException: Attempt to request all resources from an asynchronous search result.  The SearchParameterMap for this search probably should have been synchronous.</pre></td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
    },
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "Failed to call access method: ca.uhn.fhir.context.ConfigurationException: Attempt to request all resources from an asynchronous search result.  The SearchParameterMap for this search probably should have been synchronous."
        }
    ]
}

Sometimes, we're also getting this message:

{
    "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: org.springframework.transaction.IllegalTransactionStateException: Existing transaction found for transaction marked with propagation 'never'</pre></td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
    },
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "Failed to call access method: org.springframework.transaction.IllegalTransactionStateException: Existing transaction found for transaction marked with propagation 'never'"
        }
    ]
}

What are we doing wrong?
Any ideas?

view this post on Zulip Lloyd McKenzie (Jul 29 2021 at 13:17):

Suggest raising this on #hapi


Last updated: Apr 12 2022 at 19:14 UTC