spring data hadoop を使用して HDFS に簡単なテキストを書き込もうとしていました。しかし、書き込み時に不明な問題が発生しています。
スレッド「メイン」での例外 org.springframework.data.hadoop.store.StoreException: Store 出力コンテキストがまだ初期化されていません。ネストされた例外は java.io.IOException: Unexpected HTTP response: code=404 != 200, op=GETFILESTATUS, message=Not Found at org.springframework.data.hadoop.store.support.OutputStoreObjectSupport.getOutputContext(OutputStoreObjectSupport.java:135) です) org.springframework.data.hadoop.store.output.AbstractDataStreamWriter.getOutput(AbstractDataStreamWriter.java:131) で org.springframework.data.hadoop.store.output.TextFileWriter.write(TextFileWriter.java:132) で com. com.mstack.app.MainApp.main(MainApp.java:32) の mstack.app.MainApp.someMethod(MainApp.java:37) 原因: java.io.IOException: 予期しない HTTP 応答: code=404 != 200 、op=GETFILESTATUS、メッセージ=org.apache で見つかりません。
私のapplication-context.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:hdp="http://www.springframework.org/schema/hadoop" 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">
<hdp:configuration id="hadoopConfigBean">
fs.defaultFS=${hdp.fs}
</hdp:configuration>
<context:annotation-config />
<beans:bean id="textFileWriter"
class="org.springframework.data.hadoop.store.output.TextFileWriter">
<beans:constructor-arg index="0" ref="hadoopConfigBean"></beans:constructor-arg>
<beans:constructor-arg index="1"
type="org.apache.hadoop.fs.Path" value="/user/mhduser"></beans:constructor-arg>
<beans:constructor-arg index="2" type="org.springframework.data.hadoop.store.codec.CodecInfo" >
<beans:null></beans:null>
</beans:constructor-arg>
</beans:bean>
<context:property-placeholder location="hadoop-configs.properties" />
</beans:beans>
メインクラス:-
public class MainApp {
@Autowired
TextFileWriter textFileWriter;
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/application-context.xml",
MainApp.class);
System.out.println("Context loaded...");
MainApp obj = new MainApp();
context.getAutowireCapableBeanFactory().autowireBean(obj);
obj.someMethod();
}
private void someMethod() {
try {
textFileWriter.write("Something");
} catch (IOException e) {
e.printStackTrace();
}
}
}
どんな助けでも大歓迎です!ありがとう