OpenMrs startup Fails and stuck at Refreshing Context when I try to run OAuth module with Reference Application

When I am trying to run OAuth module with Reference Application 2.7 , the startup gets stuck at Refreshing Context. Its stuck since 40 mins.

here are logs : https://pastebin.com/HVcjtz6H

@dkayiwa can you help me out please?

Can you point us to the source of the module that you are running?

this is the OAuth module I am using.

@dkayiwa you wanted this only right?

I cloned and run it. It does not hang. Though it throws a number of spring bean creation exceptions

That happens… I am running it with reference application 2.7 all omods a total of 40 omod files.

And even I dont know the reason why the errors are coming.

Please help me with that too :confused:

Did that happen after your changes? Or does the original code that you forked result into the same error?

The original code runs well with legacy, FHIR and REST module. However, when we add the RefApp modules (including appframework, chart, etc.) The module gives those bean creation errors.

Can you start again from a working version? Then add the modules one by one to get the culprit?

Yes @dkayiwa I asked @pkatopenmrs to find the culprit module over a call earlier today. He’s identified it to be the appframework module and the other modules which RefApp module is dependent upon.

Actually emrapi module which is dependent upon appframework which is required for reference application module is the culprit. I added one by one and saw the same.

The bean creation errors are coming for the services of appframework module.

Let me put it this way, if one got the non forked module, what is that one change that they need to add to get this error? Try to be specific.

Let me tell you clearly the scenarios. If I take the original code(the one before this gsoc). Then i get bean validation errors stating that there are two matching beans for validatorFactory. This is the code : https://github.com/openmrs/openmrs-module-oauth2?files=1

Now if i take load the changed module( which is the one i made changes to) then i get these bean creation errors. This case is the one you tried @dkayiwa

In other words, the original code (non forked) already results into spring bean errors? And hence can not load the module?

Yes @dkayiwa the original non forked code produces this error. The code was migrated to be compatible with OMRS 2.x by me as a part of GSoC last year and it produces these errors when running with RefApp omod and other linked omods. I am trying to debug and fix this from my end and I would love your help with this since I don’t have much expertise with RefApp or the associated modules which cause this error.

Since all of the work last year involved Legacy UI, FHIR and REST, the code was never tested against RefApp. However, this year we have a deliverable of creating an OWA and we need the module to be compatible with all other modules so that the OMRS community can use it without any restrictions.

1 Like

adding primary=“true” will fix the error

This is just a fix to get OMRS started. However, there are still problems with appointmentscheduling module. I’ll look more into this

@dkayiwa The fix I suggested above works…!! The error we were getting was due to spring’s inability determine what validator bean to inject into. So making that bean “primary” fixed this. This can be done using @Primary if on an annotation based configuration.

So @pkatopenmrs go to https://github.com/openmrs/openmrs-module-appframework/ under the option tags find the version of the module you are looking for eg. 2.9 then download it. Make the changes to the xml file like I suggested and build the .omod file again. Replace this omod file.

Thanks @mavrk and @dkayiwa. Now i will proceed :slight_smile: as suggested :smiley:

I am facing same issue and tried your solution but it didnt worked. I am using
openMRS version:2.1.1
appframework-module version : 2.14
oauth2-module : latest from github

Please help @mavrk