You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.dtd declaration 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.
This has been addressed through a redirection to spring-beans-2.0.dtd for any spring-beans.dtd declaration. 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 old spring-beans.dtd file.
This will be available in the upcoming 4.2 snapshot tonight and also in a new 4.1.6 snapshot by Monday.
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.
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:
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
Reference URL: http://stackoverflow.com/questions/28371328/can-a-spring-4-application-support-spring-beans-dtd-when-it-is-run-in-a-firewall
Issue Links:
Referenced from: commits 8e4bfa9, 2de5faf
The text was updated successfully, but these errors were encountered: