title: Storm-Kafka : java.lang.NoClassDefFoundError: com/google/common/base/Strings
body: <p>I am trying to run a storm LocalCluster using storm-core 1.0.2 and kafka-spout 1.0.2.</p>
  
  <p>My pom file looks like below</p>
  
  <pre><code>  &lt;dependencies&gt;
    &lt;!-- Storm Dependency --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.storm&lt;/groupId&gt;
          &lt;artifactId&gt;storm-core&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Storm Kafka Dependency --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.storm&lt;/groupId&gt;
          &lt;artifactId&gt;storm-kafka&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.apache.zookeeper&lt;/groupId&gt;
                  &lt;artifactId&gt;zookeeper&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;log4j&lt;/groupId&gt;
                  &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
   .....
   &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources&lt;/directory&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
      &lt;plugins&gt;
  
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;single&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;descriptorRefs&gt;
                      &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                  &lt;/descriptorRefs&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;mainClass&gt;com.walmartlabs.midas.storm.Topology&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.2.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;exec&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;executable&gt;java&lt;/executable&gt;
                  &lt;includeProjectDependencies&gt;true&lt;/includeProjectDependencies&gt;
                  &lt;includePluginDependencies&gt;false&lt;/includePluginDependencies&gt;
                  &lt;classpathScope&gt;compile&lt;/classpathScope&gt;
                  &lt;mainClass&gt;${storm.topology}&lt;/mainClass&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I use following command to run storm cluster locally.</p>
  
  <pre><code>mvn package
  storm  jar target/myproject-0.1-SNAPSHOT-jar-with-dependencies.jar com.company.project.storm.Topology
  </code></pre>
  
  <p>I get following exception </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Strings
      at org.apache.storm.kafka.KafkaSpout.declareOutputFields(KafkaSpout.java:184)
      at org.apache.storm.topology.TopologyBuilder.getComponentCommon(TopologyBuilder.java:431)
      at org.apache.storm.topology.TopologyBuilder.createTopology(TopologyBuilder.java:135)
      at com.walmartlabs.midas.storm.Topology.submitLocalTopology(Topology.java:50)
      at com.walmartlabs.midas.storm.Topology.main(Topology.java:75)
  Caused by: java.lang.ClassNotFoundException: com.google.common.base.Strings
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
  </code></pre>
  
  <p>The google common dependency is that of storm-kafka artifact. And i have set the scope of storm-kafka as default so i believe all its dependency should be build in my jar.</p>
  
  <p>If i replace KafkaSpout with a simple spout that is just reading some file, everything works fine.
  I believe while packaging the jar i am not packaging all the dependencies of storm-kafka artifact.What is wrong here?  </p>