title: Getting java.lang.ClassNotFoundException: com.google.gson.Gson for maven project
body: <p>I am new to maven.I am using apache-maven-3.2.2 for building my project.Its simple project which will received json data from client side and on server side it will convert this json data to its analogous java class.For conversion of json to java format we are using google's Gson library.Without maven my project is running properly.but when I converted it to maven then I got the following error:</p>
  
  <pre><code>   Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
     at com.edfx.tsn.web.controller.DataController.transferData(DataController.java:51) [classes:]
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]
     at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
     at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
     at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
     ... 22 more
  </code></pre>
  
  <p>From the error its pretty clear that its unable to Gson jar.</p>
  
  <p>Now below is my pom.xml file</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;TestJSON&lt;/groupId&gt;
     &lt;artifactId&gt;TestJSON&lt;/artifactId&gt;
     &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
     &lt;name&gt;TestJSON&lt;/name&gt;
    &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.2.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
          &lt;version&gt;2.2.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
          &lt;version&gt;2.2.6&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
     &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;/project&gt;
  </code></pre>
  
  <p>I am not getting any error at compile time and my project is getting deployed properly.I am using Jboss7 as.But I am getting this error at runtime when my actionListener method is getting invoked.</p>
  
  <p>I have already gone through couple of links in stackoverflow specially the below one</p>
  
  <p><a href="https://stackoverflow.com/questions/11402633/gson-is-not-being-imported-into-the-maven-pproject">GSON is not being imported into the maven pproject</a></p>
  
  <p>but it didn't serve my purpose.Can anyone provide any solution to this.Thanks in advance.</p>