Question

I just get the last stable Hadoop version (2.4) and followed this instruction to import it into Eclipse.

However, I've having several build errors of cannot be resolved to a type in the test src folder. As an example:

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto;
import org.apache.hadoop.ipc.protobuf.TestProtos.EchoResponseProto;
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto;
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyResponseProto;
import org.apache.hadoop.ipc.protobuf.TestRpcServiceProtos.TestProtobufRpcProto;
import org.apache.hadoop.ipc.protobuf.TestRpcServiceProtos.TestProtobufRpc2Proto;

Eclipse cannot find any of these classes, simply because org.apache.hadoop.ipc.protobuf package is empty. Am I doing something wrong? Missing some configuration step?

Was it helpful?

Solution

You cannot find any Java files under these packages in the hadoop source code repository. Java files under this packages will be generated by protoc compiler

When you execute maven install mvn install -DskipTests protoc compiler will generate the corresponding .java files

For Setting up hadoop build environment, refer the following link

http://wiki.apache.org/hadoop/HowToContribute

Install native libraries Install protobuf etc. Refer above link for detailed information

Once you successfully execute the command mvn install -DskipTests you can see the java files under protobuf packages

OTHER TIPS

Try cd to path "/hadoop-common-project/hadoop-common/src/test/proto" and execute following command:protoc --java_out=../java *.proto. Please note that you should have protocol buffers (A Google project) properly installed, which you may simply get from github.

The protobuf related java files are in your ${project.build.directory}/generated-sources/java, where project.build.directory in my condition is <module_path>/target. So the full path is <module_path>/target/generated-sources/java. I use Intellij idea, after I marking the aforementioned full path as sources root, everything is ok. In your contition, you can try to mark <your_hadoop_project_root_path>/hadoop-common-project/hadoop-common/target/generated-sources/java as sources root.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top