spring-securityosgispring-4eclipse-virgoeclipse-gemini

getting 'Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]' with spring 4


I am upgrading spring versions of our OSGi project to spring 4.2.x.

I have removed Spring DM dependencies and add Gemini Blueprint dependencies (org.eclipse.gemini.blueprint.core,org.eclipse.gemini.blueprint.extender,org.eclipse.gemini.blueprint.io) and those are in ACTIVE state in Virgo RT server.
I have added spring-security-config dependency and it is also in ACTIVE state.

But I am facing following issue

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] Offending resource: URL [bundleentry://157.fwk1212103909/META-INF/spring/applicationContext-security.xml]

my applicationContext-security.xml file is like this

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:security="http://www.springframework.org/schema/security"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/security
       http://www.springframework.org/schema/security/spring-security.xsd">

  <security:global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager"
secured-annotations="enabled">
    <security:expression-handler ref="expressionHandler" />
  </security:global-method-security> 

  ... 

</beans>

I have used the xsd with versions. same result.

any idea what is causing this issue?


Solution

  • I had to add following line to META-INF/spring.handlers file in my project.

    http\://www.springframework.org/schema/security=org.springframework.security.config.SecurityNamespaceHandler