hapi-fhir-jpaserver-starter icon indicating copy to clipboard operation
hapi-fhir-jpaserver-starter copied to clipboard

DSTU2 Binary resource creation fails

Open edclement opened this issue 5 years ago • 1 comments

I was running into an issue trying to create Binary DSTU2 resources. To ensure it wasn't some issue with my code, I pull down the this project (master branch) and attempted the same and encountered the same issue. This is the result: image

Edit

I noticed the HAPI FHIR DSTU2 test server at: http://hapi.fhir.org/home?serverId=hapi_dev&pretty=false doesn't have this issue. I set binary_storage.enabled=false in src/main/resources/hapi.properties and that seems to have fixed the issue. Is setting this flag to false the equivalent of always storing the base64 encoded binary data in the database?

Original Post

Steps to reproduce:

  1. clone this repo
  2. update src/main/resources/hapi.properties and set fhir_version=DSTU2
  3. mvn jetty:run
  4. try POST'ing a Binary resource:
    {
      "resourceType": "Binary",
      "contentType": "text/plain",
      "content": "YXNkYXNkYXNkYXNkYXNk"
    }
    

The exact line it fails on: image

Stack Trace

Caused by: java.lang.ClassCastException: ca.uhn.fhir.model.primitive.Base64BinaryDt incompatible with org.hl7.fhir.instance.model.api.IBaseHasExtensions
	at ca.uhn.fhir.jpa.binstore.BinaryAccessProvider$2.getTarget(BinaryAccessProvider.java:311)
	at ca.uhn.fhir.jpa.binstore.BinaryAccessProvider.replaceDataWithExtension(BinaryAccessProvider.java:211)
	at ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor.extractLargeBinaries(BinaryStorageInterceptor.java:212)
	at ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor.extractLargeBinariesBeforeCreate(BinaryStorageInterceptor.java:125)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at ca.uhn.fhir.interceptor.executor.InterceptorService$HookInvoker.invoke(InterceptorService.java:514)
	at ca.uhn.fhir.interceptor.executor.InterceptorService.doCallHooks(InterceptorService.java:288)
	at ca.uhn.fhir.interceptor.executor.InterceptorService.callHooks(InterceptorService.java:277)
	at ca.uhn.fhir.jpa.util.JpaInterceptorBroadcaster.doCallHooks(JpaInterceptorBroadcaster.java:42)
	at ca.uhn.fhir.jpa.dao.BaseStorageDao.doCallHooks(BaseStorageDao.java:181)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.doCreateForPostOrPut(BaseHapiFhirResourceDao.java:309)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.doCreateForPost(BaseHapiFhirResourceDao.java:240)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.lambda$create$0(BaseHapiFhirResourceDao.java:212)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao$$Lambda$1199/0000000000000000.doInTransaction(Unknown Source)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at ca.uhn.fhir.jpa.dao.tx.HapiTransactionService.execute(HapiTransactionService.java:65)
	at ca.uhn.fhir.jpa.dao.tx.HapiTransactionService.execute(HapiTransactionService.java:56)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.create(BaseHapiFhirResourceDao.java:212)
	at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.create(BaseHapiFhirResourceDao.java:197)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy226.create(Unknown Source)
	at ca.uhn.fhir.jpa.provider.JpaResourceProviderDstu2.create(JpaResourceProviderDstu2.java:73)
	... 50 common frames omitted

edclement avatar Sep 15 '20 16:09 edclement

@edclement is this still an issue for you? Are you still using DSTU2?

jkiddo avatar Mar 06 '22 18:03 jkiddo