Hapi-Fhir and JBoss EAP 7 - NPE in MethodUtil.getResourceParameters

78 views
Skip to first unread message

Mark Wardell

unread,
Apr 27, 2021, 11:13:32 AM4/27/21
to HAPI FHIR

Hello,

I am seeing an issue with using CDI on Redhat JBoss EAP 7 with hapi-fhir 5.3.3.  
The use case is

  • Servlet extending RestfulServer 
  • IResourceProvider instance injected as a CDI component into the servlet
  • Pass that resource provider instance to RestfulServer#setResourceProviders
  • The resource provider makes use of: @IncludeParam(…) Set<Include> theIncludes
  • The servlet will fail ti initialize with:

10:36:51,782 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /hapi-fhir-eap7/DiagnosticReport: javax.servlet.ServletException: Failed to initialize FHIR Restful server

    at ca.uhn.fhir.rest.server.RestfulServer.init(RestfulServer.java:1333)

Caused by: java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at ca.uhn.fhir.rest.server.method.MethodUtil.getResourceParameters(MethodUtil.java:91)
        at ca.uhn.fhir.rest.server.method.BaseMethodBinding.<init>(BaseMethodBinding.java:74)

A small reproduction project with full stack trace can be found here: https://github.com/mbw-ahc/hapi-fhir-eap7

I believe the following is going on

Redhat JBoss EAP 7.3 is using WELD 3.1 for CDI. According to https://issues.redhat.com/browse/WELD-1539 and https://issues.redhat.com/browse/WELD-2423 the weld proxies will generate methods with raw types rather than generic types.  Therefore Set<Include> original class will be just a Set in the proxy method.  This causes the exception in the hapi-fhir reflection code running against the proxy instance. 

The guidance from WELD-1539 is to “Therefore, integrators are encouraged to detect client proxies and subclasses and work around the problem via reflection. “

Although found in EAP 7.3, I expect this would be an issue in all EAP 7 versions.
First found in hapi-fhir 5.1.0 but reproduced as well in hapi-fhir 5.3.3  

Is there a way to have hapi-fhir work with these proxies?

Let me know if this is better handed as bug report.

Mark

 

 

Reply all
Reply to author
Forward
0 new messages