Dear all, I am trying to add spring security oauth2 functionality within a new module. The aim is to authenticate users throught oauth2 external provider. For that, I added these codes in webModule ApplicationContext.xml :`<?xml version="1.0" encoding="UTF-8"?>
<context:component-scan
base-package="org.openmrs.module.oauth2login.web.controller" />
<mvc:annotation-driven />
<oauth:client id="oauth2ClientContextFilter" />
<oauth:resource id="sampleResource"
type="authorization_code" client-id="vanilla"
client-secret="25e6b209-9565-4648-b387-75b9e5dfd750"
access-token-uri="${accessTokenUri}"
user-authorization-uri="${userAuthorizationUri}" />
<security:http auto-config="true" use-expressions="true">
<!-- <sec:intercept-url pattern="/use**" access="USER" /> -->
<!-- <security:intercept-url pattern="/userinfo**" access="hasRole('user')"
/> -->
<security:intercept-url pattern="/**"
access="permitAll" />
<!-- <security:form-login default-target-url="/index" /> -->
<security:logout logout-success-url="/"
logout-url="/logout.do" invalidate-session="true" />
<security:custom-filter
ref="oauth2ClientContextFilter" after="EXCEPTION_TRANSLATION_FILTER" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="user" password="user"
authorities="user" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
<context:property-placeholder
location="classpath:/oauth2.properties" />
<bean id="oauth2loginController"
class="org.openmrs.module.oauth2login.web.controller.Oauth2loginController">
<property name="restTemplate">
<oauth:rest-template resource="sampleResource" />
</property>
</bean>
<bean
class="org.openmrs.ui.framework.StandardModuleUiConfiguration">
<property name="moduleId"
value="${project.parent.artifactId}" />
</bean>
`
However, when I run the the server I got this error : ERROR - Listener.performWebStartOfModules(669) |2019-02-26 17:41:24,315| Unable to refresh the spring application context. Root Cause was: org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http:/ /www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:128) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1422) 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(DefaultBeanDefinitionDocumentR eader.java:144) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentRea der.java:100) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext .java:129) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:894) at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:866) at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:656) at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:635) at org.openmrs.web.Listener.startOpenmrs(Listener.java:266) at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42) WARN - Listener.performWebStartOfModules(698) |2019-02-26 17:41:24,330|
If I put the exact same codes in openmrs-servlet.xml in the openmrscore, it works.
Do you have any idea ? @mksd
Many Thanks. Amine