title: Running Word Count in Local cluster in Apache Storm
body: <p>I am trying to follow the book </p>
  
  <p><a href="http://my.safaribooksonline.com/9781449324025?iid=2013-12-blog-storm-book-9781449324025-SBOBlog" rel="nofollow">http://my.safaribooksonline.com/9781449324025?iid=2013-12-blog-storm-book-9781449324025-SBOBlog</a></p>
  
  <p>to run Storm cluster and create first topology. These are the steps that i followed </p>
  
  <p>1) Installed Maven</p>
  
  <p>2) Installed maven plugin for Eclipse</p>
  
  <p>3) Create new Maven project in Eclipse with artifact name as stormArtifact</p>
  
  <p>4) It generated a folder structure and a pom.xml file</p>
  
  <p>5) i updated that pom.xml as follows.</p>
  
  <p>6) I added spouts and bolts as specified in this link</p>
  
  <p><a href="https://github.com/storm-book/examples-ch02-getting_started/zipball/master" rel="nofollow">https://github.com/storm-book/examples-ch02-getting_started/zipball/master</a></p>
  
  <p>7) Now i am running it using the command</p>
  
  <pre><code>mvn exec:java -Dexec.mainClass="TopologyMain" -Dexec.args="src/main/resources/words.txt"
  </code></pre>
  
  <p>But it is throwing an error as follows</p>
  
  <pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3:java (def
  ault-cli) on project stormArtifact: The parameters 'mainClass' for goal org.code
  haus.mojo:exec-maven-plugin:1.3:java are missing or invalid -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
  ch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please rea
  d the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParamete
  rException
  </code></pre>
  
  <p><strong>My pom.xml</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;stormGroup&lt;/groupId&gt;
  &lt;artifactId&gt;stormArtifact&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;build&gt;
  &lt;plugins&gt;
  &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.3.2&lt;/version&gt;
      &lt;configuration&gt;
          &lt;source&gt;1.7&lt;/source&gt;
          &lt;target&gt;1.7&lt;/target&gt;
          &lt;compilerVersion&gt;1.7&lt;/compilerVersion&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;repositories&gt;
  &lt;!-- Repository where we can found the storm dependencies --&gt;
  &lt;repository&gt;
  &lt;id&gt;clojars.org&lt;/id&gt;
  &lt;url&gt;http://clojars.org/repo&lt;/url&gt;
  &lt;/repository&gt;
  &lt;/repositories&gt;
  &lt;dependencies&gt;
  &lt;!-- Storm Dependency --&gt;
  &lt;dependency&gt;
  &lt;groupId&gt;storm&lt;/groupId&gt;
  &lt;artifactId&gt;storm&lt;/artifactId&gt;
  &lt;version&gt;0.9.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>ToplogyMain class</strong></p>
  
  <pre><code>import spouts.WordReader;
  import backtype.storm.Config;
  import backtype.storm.LocalCluster;
  import backtype.storm.topology.TopologyBuilder;
  import backtype.storm.tuple.Fields;
  import bolts.WordCounter;
  import bolts.WordNormalizer;
  
  
  public class TopologyMain {
  public static void main(String[] args) throws InterruptedException {
  
      //Topology definition
      TopologyBuilder builder = new TopologyBuilder();
      builder.setSpout("word-reader",new WordReader());
      builder.setBolt("word-normalizer", new WordNormalizer())
          .shuffleGrouping("word-reader");
      builder.setBolt("word-counter", new WordCounter(),1)
          .fieldsGrouping("word-normalizer", new Fields("word"));
  
      //Configuration
      Config conf = new Config();
      conf.put("wordsFile", args[0]);
      conf.setDebug(false);
      //Topology run
      conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology("Getting-Started-Toplogie", conf, builder.createTopology());
      Thread.sleep(1000);
      cluster.shutdown();
  }
  }
  </code></pre>