Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no spring-beans.dtd file inside of the spring-beans-4.1.5.RELEASE jar [SPR-12836] #17433

Closed
spring-issuemaster opened this issue Mar 20, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Mar 20, 2015

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

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:

  • #15070 Create v4 XML schema
  • #16781 XML bean singleton attribute silently ignored
  • #18125 Consistently detect spring-beans.dtd reference

Referenced from: commits 8e4bfa9, 2de5faf

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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.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.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 20, 2015

Juergen Hoeller commented

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.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.