Failing to Autowire PatientReferenceTranslator

Using the latest fhir2 module within OpenMRS 2.2, i see the below error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘cohortListEntryTranslatorImpl_2_1’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.openmrs.module.fhir2.api.translators.PatientReferenceTranslator org.openmrs.module.fhir2.api.translators.impl.CohortListEntryTranslatorImpl_2_1.patientReferenceTranslator; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.openmrs.module.fhir2.api.translators.PatientReferenceTranslator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

cc @ibacher

@nbottu may you please use for easy viewing of error logs

1 Like

In addition to using, as @jnsereko suggested, it would be better if you could paste the entire log or at least the whole error chain. My immediate suspicion is that you need to remove the FHIR (not FHIR2) module from your OpenMRS 2.2 install, but that’s just a guess.

The fix was to add scope as provided to the fhir2 dependency in the module’s pom.xml file.