Repository navigation
Description
Przemek Wyszkowski opened SPR-12836 and commented
After migrating our application to Spring4 it is unable to start due to beans configured using XML DTD. The application runs behind the firewall without any access to the Internet and fails with the following error:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [rmi-exporters-spring-beans.xml]
Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:log4j-config-server-spring-beans.xml]
Offending resource: class path resource [rmi-exporters-spring-beans.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [log4j-config-server-spring-beans.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:171)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.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.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
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)
It is due to missing spring-beans.dtd file in the spring-beans.jar which used to be there in org/springframework/beans/factory/xml/spring-beans.dtd in the spring 3.2.x jars. Lack of this file breaks the backward compatibility of the applications running without the access to the Internet.
What is interesting is that spring-beans-2.0.dtd is present in the jar... However, spring does not automatically resolve to this file in the absence of spring-beans.dtd.
Currently we have added an additional jar containing this single missing file to our classpath which is a workaround for this issue, but you might take a look if the lack of the file was done intentionally.
Affects: 4.1.5
Issue Links:
- Create v4 XML schema [SPR-10437] #15070 Create v4 XML schema
- XML bean singleton attribute silently ignored [SPR-12167] #16781 XML bean singleton attribute silently ignored
- Consistently detect spring-beans.dtd reference [SPR-13549] #18125 Consistently detect spring-beans.dtd reference
Activity
spring-projects-issues commentedon Mar 20, 2015
Juergen Hoeller commented
IIRC, the removal of the spring-beans 1.x dtd was intentional, since it allowed us to drop support code for long-outdated config options that got superseded in Spring 2.0 back in 2006.
That said, a
spring-beans.dtddeclaration should still locally resolve, just automatically against the 2.0 version of the file now. Since that part doesn't seem to work, I'll have a look at it ASAP.Juergen
spring-projects-issues commentedon Mar 20, 2015
Juergen Hoeller commented
This has been addressed through a redirection to
spring-beans-2.0.dtdfor anyspring-beans.dtddeclaration. Note that you might get validation errors if your XML files contain references to the Spring 1.x 'singleton' attribute, typically setting it to 'false' for prototype scope; you'll have to replace those with Spring 2.0+scope="prototype"declarations. The parsing code for the old attribute has been removed, so it won't work with Spring 4.x in any case, even with a copy of the oldspring-beans.dtdfile.This will be available in the upcoming 4.2 snapshot tonight and also in a new 4.1.6 snapshot by Monday.
Juergen
spring-projects-issues commentedon Mar 20, 2015
Przemek Wyszkowski commented
Hi Juergen,
Thanks for your immediate response. We are aware of the outdated "singleton" attribute which anyway needs to be adapted in the configuration files - actually I forgot to mention this issue but you correctly pointed it out.
Have a nice weekend,
Cheers,
Przemek