Announcement Announcement Module
Collapse
No announcement yet.
OAuth Namespace Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OAuth Namespace Problem

    Hi spring-community,

    I would like to use our social network software as an oauth provider. So I got familiar with the sparklr and tonr example applications. Then I tried to add oauth functionality to our social network:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:security="http://www.springframework.org/schema/security"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:p="http://www.springframework.org/schema/p" 
    	xmlns:oauth="http://www.springframework.org/schema/security/oauth"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    		http://www.springframework.org/schema/context
    		http://www.springframework.org/schema/context/spring-context-3.1.xsd
    		http://www.springframework.org/schema/tx 
    		http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
    		http://www.springframework.org/schema/aop
        	http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        	http://www.springframework.org/schema/security 
        	http://www.springframework.org/schema/security/spring-security-3.1.xsd
        	http://www.springframework.org/schema/security/oauth
            http://www.springframework.org/schema/security/spring-security-oauth.xsd
        	">
    I configured the namespaces in the way the sparklr application shows me and included the spring-security 3.1 libs (oauth,web,core,taglibs,acl,config)

    Then I added the following:

    Code:
    <oauth:provider consumer-details-service-ref="consumerDetails"
    	token-services-ref="tokenServices" request-token-url="/oauth/request_token"
    	authenticate-token-url="/oauth/authorize" authentication-failed-url="/oauth/confirm_access"
    	access-token-url="/oauth/access_token" require10a="false" />
    
    	<oauth:consumer-details-service id="consumerDetails">
    		<oauth:consumer name="name" key="key"
    			secret="test" resourceName="Your Data" resourceDescription="your data from sociato" />
    	</oauth:consumer-details-service>
    
    	<oauth:token-services id="tokenServices" />
    
    
    	<bean id="accessConfirmationController" class="de.lyth.generic.util.oauth.AccessConfirmationController">
    		<property name="tokenServices" ref="tokenServices" />
    		<property name="consumerDetailsService" ref="consumerDetails" />
    	</bean>
    Trying to start our application brings the following exception:

    org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security/oauth]
    Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]

    at org.springframework.beans.factory.parsing.FailFast ProblemReporter.error(FailFastProblemReporter.java :68)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:80)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.error(BeanDefinitionParserDelegat e.java:317)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1411)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1404)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:184)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.doRegisterBeanDefinitions( DefaultBeanDefinitionDocumentReader.java:140)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:111)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:125)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:94)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:131)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:522)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:436)
    at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext(ContextLoader .java:377)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:278)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 111)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:525)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:414)

    But when I copy http://www.springframework.org/schem...rity-oauth.xsd to the adress field of the browser, I see a document.

    Could anybody explain me please how to fix this problem.

    Thanks in advance.

    Asuka

  • #2
    well .. now I used spring-security-oauth 1.0.0 instead of using spring-security-oauth 3.1 and the exception is the following:

    org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.security.oauth.config.OAuthSec urityNamespaceHandler] for namespace [http://www.springframework.org/schema/security/oauth]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/web/util/AntUrlPathMatcher
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:125)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:94)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:131)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:522)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:436)
    at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext(ContextLoader .java:377)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:278)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 111)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:525)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:414)
    Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.security.oauth.config.OAuthSec urityNamespaceHandler] for namespace [http://www.springframework.org/schema/security/oauth]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/web/util/AntUrlPathMatcher
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.resolve(DefaultNamespaceHandle rResolver.java:139)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1409)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1404)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:184)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.doRegisterBeanDefinitions( DefaultBeanDefinitionDocumentReader.java:140)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:111)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390)
    ... 28 more
    Caused by: java.lang.NoClassDefFoundError: org/springframework/security/web/util/AntUrlPathMatcher
    at org.springframework.security.oauth.config.OAuthSec urityNamespaceHandler.init(OAuthSecurityNamespaceH andler.java:31)
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.resolve(DefaultNamespaceHandle rResolver.java:130)
    ... 35 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.security.web.util.AntUrlPathMa tcher
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1526)
    ... 37 more

    Anybody an idea?

    Greetings

    Comment


    • #3
      Looks like a simple dependency / classpath problem. The Spring Security OAuth POM has a ll the required dependencies listed. Are you using Maven for dependency management (in which case sparklr should be your template)? If not then you have to make sure you have all the right jars somehow.

      Comment


      • #4
        thanks for your answer

        I solved the problem ... anyhow.. but it was not because of a dependency problem. It was because of a wrong version. With spring security 3.0.3 it works, with spring security 3.1 it does not work

        Comment


        • #5
          That is what I call a dependency problem. I think you must have an old version of Spring Security OAuth because the recent snapshots depend on Spring Security 3.1.0.RC2. RC3 is just about to come out so I'll be switching to that this week sometime probably.

          Comment

          Working...
          X