spring-attic / spring-security-oauth

Support for adding OAuth1(a) and OAuth2 features (consumer and provider) for Spring web applications.
http://github.com/spring-projects/spring-security-oauth
Apache License 2.0
4.69k stars 4.05k forks source link

The matching wildcard is strict, but no declaration can be found for element 'oauth2:resource-server #1926

Closed Staticsubh closed 3 years ago

Staticsubh commented 3 years ago

Project specifications : Spring 5.3.7 + Oauth2-2.5.1.

Attaching the context-web.xml here.

I have tried changing "http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd" to "https://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd". but no success. context-web.zip

After deploying the project, when I turn on the jboss, getting the below exception :

01:09:11,819 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 77) Context initialization failed: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: **Line 660 in XML document from ServletContext resource [/WEB-INF/context-web.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 659; columnNumber: 57; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oauth2:resource-server'.**
    at deployment.CentricityPracticeEAR.ear//org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:402)
    at deployment.CentricityPracticeEAR.ear//org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:338)
    at deployment.CentricityPracticeEAR.ear//org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    at deployment.CentricityPracticeEAR.ear//org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: **org.xml.sax.SAXParseException; lineNumber: 659; columnNumber: 57; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oauth2:resource-server'.**
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:201)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:394)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:282)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:482)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3583)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2156)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:809)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:275)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1653)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:875)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)

Can somebody please suggest me a fix or workaround for this.

Staticsubh commented 3 years ago

Can someone please provide an update to this

Staticsubh commented 3 years ago

Closing the issue as the exception got resolved by changing "http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd" to "https://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd". Earlier I was changing http to https for all other Oauth references in that file. changing on that specific line helped.

Thanks for the support.