Description
Paul Bakker opened SPR-14579 and commented
As part of the work I'm doing for the upcoming Java 9 book for O'Reilly I'm experimenting with migration scenarios towards Java 9 modules.
The scenario is the following. The user migrated her code to a module (meaning that a module-info.java was added). The code relies on a Spring version which is not yet Java 9 compatible. This should't be a problem, because existing libraries should be able to work as "automatic modules". This works well with Spring, up until the point that namespaces in the xml configuration are used.
<context:component-scan base-package="org.example"/>
This results in the following error:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [services.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(spring.beans@4.3.2.RELEASE/FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(spring.beans@4.3.2.RELEASE/ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(spring.beans@4.3.2.RELEASE/ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(spring.beans@4.3.2.RELEASE/BeanDefinitionParserDelegate.java:301)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(spring.beans@4.3.2.RELEASE/BeanDefinitionParserDelegate.java:1408)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(spring.beans@4.3.2.RELEASE/BeanDefinitionParserDelegate.java:1401)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(spring.beans@4.3.2.RELEASE/DefaultBeanDefinitionDocumentReader.java:172)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(spring.beans@4.3.2.RELEASE/DefaultBeanDefinitionDocumentReader.java:142)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(spring.beans@4.3.2.RELEASE/DefaultBeanDefinitionDocumentReader.java:94)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(spring.beans@4.3.2.RELEASE/XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(spring.beans@4.3.2.RELEASE/XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(spring.beans@4.3.2.RELEASE/AbstractBeanDefinitionReader.java:252)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(spring.context@4.3.2.RELEASE/AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(spring.context@4.3.2.RELEASE/AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(spring.context@4.3.2.RELEASE/AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(spring.context@4.3.2.RELEASE/AbstractApplicationContext.java:612)
at org.springframework.context.support.AbstractApplicationContext.refresh(spring.context@4.3.2.RELEASE/AbstractApplicationContext.java:513)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(spring.context@4.3.2.RELEASE/ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(spring.context@4.3.2.RELEASE/ClassPathXmlApplicationContext.java:93)
at demo.bootstrapper.Main.setup(bootstrap/Main.java:11)
at demo.bootstrapper.Main.main(bootstrap/Main.java:16)
I'm not suggesting this is an error in Spring, or that this must be fixed, but hopefully it's useful information for compatibility issues in the future.
A (pretty bad) workaround is to extract the META-INF folder from the JAR file and put that on the classpath.
Affects: 5.0 M1
Issue Links:
- Declare Spring modules with JDK 9 module metadata [SPR-13501] #18079 Declare Spring modules with JDK 9 module metadata
- Stable module names for Spring Framework jars on JDK 9 module path [SPR-13716] #18289 Stable module names for Spring Framework jars on JDK 9 module path
- DATACMNS-1033 Assert Java 9 compatibility
- Compatibility with merged JDK 9 mainline [SPR-13344] #17928 Compatibility with merged JDK 9 mainline
- Compatibility with JDK 9 GA [SPR-15992] #18941 Compatibility with JDK 9 GA
Referenced from: commits 6ef7dd4
0 votes, 9 watchers