Search code examples
hadoopnoclassdeffounderroraccumulo

java.lang.NoClassDefFoundError: org/apache/accumulo/core/client/Instance


I'm using small program to write data into Accumulo.

Program worked when added jars manually. But, when build with maven, with the same version's used from manual it throws:

java.lang.NoClassDefFoundError: org/apache/accumulo/core/client/Instance.

How would I resolve it?


Solution

  • Your job is going to be run on all of the nodes in your MR network. You'll need the appropriate jars on all of the nodes in order for it to work.

    Another approach, as you have noticed, is to just include everything into one uber jar, which contains everything that you need. That way when your job gets shipped to each node, you'll have everything you need. One way to accomplish this with maven is through the use of plugins:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/hadoop-job.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    Inside of your hadoop-job.xml you might have

    <assembly>
      <id>job</id>
      <formats>
       <format>jar</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <dependencySets>
        <dependencySet>
          <unpack>false</unpack>
          <scope>runtime</scope>
          <outputDirectory>lib</outputDirectory>
          <excludes>
            <exclude>${groupId}:${artifactId}</exclude>
          </excludes>
        </dependencySet>
        <dependencySet>
          <outputDirectory></outputDirectory>
          <unpack>true</unpack>
          <includes>
            <include>${groupId}:${artifactId}</include>
          </includes>
        </dependencySet>
      </dependencySets>
    </assembly>
    

    More information about this plugin may be found at http://maven.apache.org/plugins/maven-assembly-plugin/