Error during getting registered component

Hi, I am working on FHIR Module. I am trying to implement compatibility to support different openmrs versions and am stuck with this error:

Caused by: org.openmrs.api.APIException: Error during getting registered component.
at org.openmrs.api.context.ServiceContext.getRegisteredComponent(ServiceContext.java:901)
at org.openmrs.api.context.Context.getRegisteredComponent(Context.java:1201)
at org.openmrs.module.fhir.api.util.ContextUtil.getConditionHelper(ContextUtil.java:31)
at org.openmrs.module.fhir.api.strategies.condition.ConditionStrategy.createFHIRCondition(ConditionStrategy.java:31)
at org.openmrs.module.fhir.api.impl.ConditionServiceImpl.createFHIRCondition(ConditionServiceImpl.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:52)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:303)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy187.createFHIRCondition(Unknown Source)
at org.openmrs.module.fhir.resources.FHIRConditionResource.createFHIRCondition(FHIRConditionResource.java:69)

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'fhir.ConditionHelper' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:694)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:962)
at org.openmrs.api.context.ServiceContext.getRegisteredComponent(ServiceContext.java:898)

In All of the api sub-module. I have registered to the context with the same name “fhir.ConditionHelper”

@Component(value = "fhir.ConditionHelper")
@OpenmrsProfile(openmrsPlatformVersion = "2.2.* ")
public class ConditionHelperImpl2_2 implements ConditionHelper {

Below is the link to PR (Work in Progress) with all changes made.

Need help figuring out what am doing wrong or haven’t?

Which OpenMRS platform version are you running?

Openmrs platform 2.2

Add another dependency for fhir-api-2.2 like this one: https://github.com/openmrs/openmrs-module-fhir/blob/master/omod/pom.xml#L82-L86

I added fhir-api-2.2 dependency to the omod didn’t work, still the same error

Did you commit that change?

No I haven’t

While I was debugging I found this method:

Context.getAdministrationService().getGlobalProperty("fhir.condition.strategy");

yet I specify global property property in the config file:

	<globalProperty>
	<property>${project.parent.artifactId}.condition.strategy</property>
	<defaultValue>DefaultConditionStrategy</defaultValue>
	<description>Set condition strategy</description>
</globalProperty>

There is something I am missing out. It seems can’t neither register to the Context nor retrieve from! :frowning:

@dkayiwa help me figure this

Have you committed your changes yet?

Yes. I have committed.

What is the exact version of the OpenMRS platform as it appears in the footer of your browser?

Version 2.2.0

I have just compiled your changes and installed the module on platform 2.2.x with out any errors. You may need to cross check again?

I am getting the error when i tried to access the condition endpoint. I have no problem deploying. it does successful. But when I try accessing the endpoint I have exposed. It throws the error above.

What is the exact end point?

POST request to: /openmrs/ws/fhir/Condition

sample body

 {
    "resourceType": "Condition",
    "id": "92A45BE7A93A4E14A49CB9A51E19C3A4",
    "subject": {
      "reference": "Patient/D1A903924D4443A7A388778D77D86155"
    },
    "clinicalStatus": "active",
    "code": {
      "coding": {
        "system": "http://snomed.info/sct",
        "code": "236578006",
        "display": "Chronic rejection of renal transplant (disorder)"
      },
      "text": "Chronic rejection of renal transplant (disorder)"
    },
    "onsetDateTime": "2011-12-31"
}

Change the package of the ConditionHelperImpl2_2 class from helper to org.openmrs.module.fhir.helper

Thanks @dkayiwa it worked. I never considered checking for package my bad :frowning_face: