vendredi 13 mars 2015

Unable to locate Spring META-INF\spring.handler for XML schema namespace [http://ift.tt/OGfeU2]

I am using spring in OSGI plugin as dependency. Have added the spring-config file in the resource path of my plugin. When i try to create ApplicationContext using ClassPathXmlApplicationContext("spring-config.xml"), The class loader was not able to find the config file resource since the Thread that loaded this class was different than the thread which is trying find the plugin resource. So i set the classLoader to current thread context as mentioned below. This solved the spring-config.xml file load, but now it seems that the The META-INF\spring.handler and META-INF\spring.schema files are not being loaded as it is again trying to search these file in the plugin resource while it is actually present in the spring.jar, The code is shown below:



Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
ApplicationContext context = new ClassPathXmlApplicationContext(
"/spring-config.xml",this.getClass());


Exception being thrown is


org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://ift.tt/OGfeU2] Offending resource: class path resource [/spring-config.xml]



at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:275)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1243)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1236)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:108)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:411)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:338)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:180)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:155)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:141)
at com.infa.products.idv.result.RunResultRepositoryServiceImpl.init(RunResultRepositoryServiceImpl.java:18)
at com.infomratica.products.idv.services.extensionpoint.IDVServiceExtensionReader.getInstance(IDVServiceExtensionReader.java:43)
at com.infomratica.products.idv.services.interfaces.IDVServiceProvider.getRunResultRepositoryService(IDVServiceProvider.java:79)
at com.infa.products.idv.tasks.RunTablePairTask.syncResultMetadata(RunTablePairTask.java:87)
at com.infa.products.idv.tasks.RunTablePairTask.execute(RunTablePairTask.java:37)
at com.infa.products.idv.taskexecutor.TaskExecutorImpl$CallableWrapper.call(TaskExecutorImpl.java:121)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Aucun commentaire:

Enregistrer un commentaire