I am using HAPI FHIR JPA server version 7.0.0 that is using FHIR version R5. It is also using a custom IG.
I tested the validation API on a FHIR bundle XML of the drug label for Ibrance. However, I received this error message from the server:
2025-07-23 20:43:05.887 [http-nio-8080-exec-5] ERROR c.u.f.r.s.i.ExceptionHandlingInterceptor [ExceptionHandlingInterceptor.java:198] Failure during REST processing
ca.uhn.fhir.rest.server.exceptions.InternalErrorException: HAPI-0389: Failed to call access method: java.lang.Error: Attempt to read a single element when there is more than one present (subject)
at ca.uhn.fhir.rest.server.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:272)
at ca.uhn.fhir.rest.server.method.OperationMethodBinding.invokeServer(OperationMethodBinding.java:399)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:146)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:275)
at ca.uhn.fhir.rest.server.method.OperationMethodBinding.invokeServer(OperationMethodBinding.java:356)
at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:1198)
at ca.uhn.fhir.rest.server.RestfulServer.doPost(RestfulServer.java:436)
at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1937)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at ca.uhn.fhir.rest.server.method.BaseMethodBinding.invokeServerMethod(BaseMethodBinding.java:264)
... 37 common frames omitted
Caused by: java.lang.Error: Attempt to read a single element when there is more than one present (subject)
at org.hl7.fhir.r5.elementmodel.Element.getNamedChild(Element.java:702)
at org.hl7.fhir.validation.instance.type.BundleValidator.validateDocumentReference(BundleValidator.java:515)
at org.hl7.fhir.validation.instance.type.BundleValidator.validateDocument(BundleValidator.java:450)
at org.hl7.fhir.validation.instance.type.BundleValidator.validateBundle(BundleValidator.java:72)
at org.hl7.fhir.validation.instance.InstanceValidator.checkSpecials(InstanceValidator.java:5219)
at org.hl7.fhir.validation.instance.InstanceValidator.startInner(InstanceValidator.java:5198)
at org.hl7.fhir.validation.instance.InstanceValidator.start(InstanceValidator.java:4980)
at org.hl7.fhir.validation.instance.InstanceValidator.validateResource(InstanceValidator.java:6484)
at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:919)
at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:753)
at org.hl7.fhir.common.hapi.validation.validator.ValidatorWrapper.validate(ValidatorWrapper.java:171)
at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validate(FhirInstanceValidator.java:239)
at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:23)
at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:59)
at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:27)
at ca.uhn.fhir.validation.FhirValidator.validateResource(FhirValidator.java:357)
at ca.uhn.fhir.validation.FhirValidator.doValidate(FhirValidator.java:273)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:241)
at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.validate(BaseHapiFhirResourceDao.java:2588)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:351)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:385)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:717)
at ca.uhn.fhir.jpa.dao.JpaResourceDaoBundle$$SpringCGLIB$$0.validate(<generated>)
at ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider.validate(BaseJpaResourceProvider.java:367)
at ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider.validate(BaseJpaResourceProvider.java:355)
... 42 common frames omitted
The error seems to be coming from the server code, not the validation result itself. Based on what I have tested, the error is caused by the first Composition resource entry in the FHIR bundle XML. This Composition resource has three subject elements. The error message seems to be referring to this.
When I remove two of the subject elements in that Composition element and run the validation, it returns proper validation results. Though, the validation results says there are errors in the bundle, which are due to the two subject elements being removed.
Should a Composition element be able to handle having more than one subject element? If so, is this an error in the HAPI FHIR code itself that needs to be fixed? Or is there an issue with the XML bundle itself?
If there is not supposed to be multiple subject elements in a Composition element, is there a way to avoid this error?
I have attached the FHIR Ibrance drug label bundle XML I tested with. The multiple subject elements start at Line 47.
The custom FHIR IG we are working with can be found here: https://github.com/HL7/fhir-spl/blob/R5/package/hl7.fhir.us.spl.tgz