java.lang.NoClassDefFoundError:org / springframework / data / hadoop / configuration / ConfigurationFactoryBean

时间:2015-08-03 08:17:35

标签: spring hadoop

我正在使用hadoop2.5.2,spring4.1,spring-data-hadoop2.0.0 RELEASE。

每当我在spring bean配置文件

中使用Spring Hadoop命名空间指定配置标记时

Spring Data Hadoop XML配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/hadoop"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">

<context:property-placeholder location="hadoop.properties"/>
<configuration>
    fs.defaultFS=${hd.fs}
    yarn.resourcemanager.address=${hd.rm}
    mapreduce.framework.name=yarn
    mapreduce.jobhistory.address=${hd.jh}
</configuration>
<job id="samplejob"
    input-path="${input.path}" 
    output-path="${output.path}"
    jar-by-class="com.ihub.BookXDriver"
    mapper="com.ihub.BookXMapper"
    reducer="com.ihub.BookXReducer"/>
<job-runner id="runner" run-at-startup="true"
    job-ref="samplejob" />    
</beans:beans>

堆栈跟踪:

2015-08-03 12:32:04,930 INFO  [main] support.ClassPathXmlApplicationContext (AbstractApplicationContext.java:prepareRefresh(510)) - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@53533c55: startup date [Mon Aug 03 12:32:04 IST 2015]; root of context hierarchy
2015-08-03 12:32:05,067 INFO  [main] xml.XmlBeanDefinitionReader (XmlBeanDefinitionReader.java:loadBeanDefinitions(317)) - Loading XML bean definitions from class path resource [com/ihub/config.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [com/ihub/config.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/hadoop/configuration/ConfigurationFactoryBean
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
    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:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
    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)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.ihub.BookXDriver.main(BookXDriver.java:50)
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/hadoop/configuration/ConfigurationFactoryBean
    at org.springframework.data.hadoop.config.HadoopConfigParser.getBeanClass(HadoopConfigParser.java:32)
    at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:66)
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:60)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
    at org.springframework.data.hadoop.config.HadoopNamespaceHandler.parse(HadoopNamespaceHandler.java:70)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:174)
    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)
    ... 14 more
Caused by: java.lang.ClassNotFoundException: org.springframework.data.hadoop.configuration.ConfigurationFactoryBean
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 26 more

1 个答案:

答案 0 :(得分:0)

此错误:

java.lang.ClassNotFoundException: org.springframework.data.hadoop.configuration.ConfigurationFactoryBean

指出你的项目类路径中缺少一些jar。

ConfigurationFactoryBean类存在于spring-data-hadoop2.0.0 RELEASE中。因此,请确保此jar存在于项目类路径中。

如果需要的jar存在但仍然收到此错误,那么它只是放置jar的路径不会被视为项目的类路径。