Description
Issue Summary
On attempting to start Bitbucket 7.0.0 on a server that has no outbound network connectivity, the following warning and error message is thrown and Bitbucket fails to start:
2020-03-07 13:00:48,606 WARN [spring-startup] o.s.b.f.xml.XmlBeanDefinitionReader Ignored XML validation warning org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. ... 2020-03-07 13:00:48,611 ERROR [spring-startup] c.a.j.s.w.s.JohnsonDispatcherServlet SpringMVC dispatcher [springMvc] could not be started org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [security-context.xml] Offending resource: class path resource [stash-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [security-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 74; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'sec:global-method-security'. at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72) 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:133) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:637) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at java.lang.Thread.run(Thread.java:748) ... 22 frames trimmed Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [security-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 74; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'sec:global-method-security'. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:405) ... 8 common frames omitted Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'sec:global-method-security'. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) ... 8 common frames omitted
Steps to Reproduce
- Install Bitbucket 7.0.0
- Completely disable outbound network connectivity
- Attempt to start Bitbucket
Expected Results
Bitbucket uses the embedded XSD files in spring-security-config-5.2.1.RELEASE.jar, and starts without attempting to reach out to springframework.org
Actual Results
Spring 5.2.1 is unable to recognize the line http://www.springframework.org/schema/security/spring-security.xsd in our security-context.xml file as mapping to a xsd bundled within the spring-security-config-5.2.1.RELEASE.jar file, due to the following Spring 5.2.1 bug:
Workaround
Within the $BITBUCKET_INSTALL/app/WEB-INF/classes/security-context.xml file replace the line:
http://www.springframework.org/schema/security/spring-security.xsd">
with the line
https://www.springframework.org/schema/security/spring-security.xsd">