ssmusoke
(Stephen Senkomago Musoke)
May 23, 2018, 6:23am
1
I am in the process of integrating the openmrs-module-cohort and I have run into a situation of 2 controllers (PatientSearchController) have the same name hence cannot be loaded by Spring.
Same Controller Name in different modules - Cohort and HTML Widgets
Listener.performWebStartOfModules(671) |2018-05-23 09:17:25,890| Unable to refresh the spring application context. Root Cause was:
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'patientSearchController' for bean class [org.openmrs.module.cohort.web.controller.PatientSearchController] conflicts with existing, non-compatible bean definition of same name and class [org.openmrs.module.htmlwidgets.web.controller.PatientSearchController]
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:320)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:259)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:87)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:174)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
This file has been truncated. show original
Any advice on how to handle this for this instance and going forward
ssmusoke
(Stephen Senkomago Musoke)
May 23, 2018, 7:18am
3
@dkayiwa Please can you show me an example of the recommended approach for webservice API test with mocking that I can use
wyclif
(Wyclif Luyima)
May 23, 2018, 1:57pm
4
You should specify a name for at least one of the controllers so that spring doesn’t use its default naming for beans, like @Component annotation the @Controller annotation has a value attribute for this purpose.
ssmusoke
(Stephen Senkomago Musoke)
May 23, 2018, 6:52pm
5
@wyclif Do advise on the two:
I think Cohort module is easier to change at this time
wyclif
(Wyclif Luyima)
May 23, 2018, 7:20pm
6
@ssmusoke there is no need to rename any of the controllers, in my response I mentioned that all you need to do is to specify a name for one of the controllers as shown below:
@Controller("myController")
public class MyController {
......
}
wyclif
(Wyclif Luyima)
May 23, 2018, 7:22pm
7
Possibly do it for both controllers just in case there is another module with a controller with the same name.