title: NoClassDefFoundError: com/google/common/reflect/TypeToken
body: <p>I have been using <a href="https://github.com/Ecwid/ecwid-mailchimp/wiki" rel="nofollow">this</a> api. The API is a Java wrapper for Mailchimp API  with maven dependency.</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.ecwid&lt;/groupId&gt;
      &lt;artifactId&gt;ecwid-mailchimp&lt;/artifactId&gt;
      &lt;version&gt;2.0.1.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I didn’t have trouble working with their API so far. But now I see this strange exception:</p>
  
  <pre><code>Exception in thread "Timer-2" java.lang.NoClassDefFoundError: com/google/common/reflect/TypeToken
  at com.ziprealty.subscription.MailChimpNewsSubscriptionProcessor.updateAllUnSubscribedEmails(MailChimpNewsSubscriptionProcessor.java:84)
  at com.ziprealty.job.MailChimpSubscriptionProcessor.processTask(MailChimpSubscriptionProcessor.java:29)
  at com.ziprealty.job.JobBase.run(JobBase.java:96)
  at java.util.TimerThread.mainLoop(Timer.java:555)
  at java.util.TimerThread.run(Timer.java:505)
  Caused by: java.lang.ClassNotFoundException: com.google.common.reflect.TypeToken
  at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
  at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
  ... 5 more
  </code></pre>
  
  <p>And here is the code for updateAllUnSubscribedEmails</p>
  
  <pre><code>public void updateAllUnSubscribedEmails( Date lastRunDate, String brandCode,Logger logger){
  
  
      logger.log(Level.SEVERE, "Entering mail chimp subscription processor in boardwalk for :" + brandCode);
      logger.log(Level.SEVERE, "Last run date is :" + lastRunDate);
      System.out.println("Entering mail chimp subscription processor in boardwalk for :" + brandCode);
  
      try {
  
          MailChimpSubscriptionDAO subscriptionDAO = MailChimpSubscriptionDAO.INSTANCE;
          MailChimpSubscription  subscription= subscriptionDAO.getMailChimpSubscriptionByBrandCode(brandCode);
  
          logger.log(Level.SEVERE,"Subscription object is :"+ subscription);
  
          **ListMembersMethod listMembersMethod= new ListMembersMethod();**
  
          logger.log(Level.SEVERE,"listMembersMethod object is :"+ listMembersMethod);
          listMembersMethod.status= MemberStatus.unsubscribed;
          logger.log(Level.SEVERE,"listMembersMethod.status object is :"+ listMembersMethod.status);
          listMembersMethod.apikey=mailChimpApiKey;
          logger.log(Level.SEVERE,"listMembersMethod.apikey object is :"+ listMembersMethod.apikey);
          listMembersMethod.id=subscription.getEmailListId();
          logger.log(Level.SEVERE,"listMembersMethod.id object is :"+ listMembersMethod.id);
  
          listMembersMethod.since= lastRunDate;
          .
      .
      .
      .
  
      } catch (IOException e) {
          e.printStackTrace();
          System.out.println(e.getMessage());
          logger.log(Level.SEVERE, e.getMessage());
      } catch (MailChimpException e) {
          e.printStackTrace();
          System.out.println(e.getMessage());
          logger.log(Level.SEVERE, e.getMessage());
      }
      catch (Exception e){
          e.printStackTrace();
          System.out.println(e.getMessage());
          logger.log(Level.SEVERE, e.getMessage());
      }
  
      finally {
  
          logger.log(Level.SEVERE,"Finally block ...Try catch block ended");
      }
  
      logger.log(Level.SEVERE,"After finally Try catch block  without exception  ");
  
  
  }
  </code></pre>
  
  <p>The code stops working at this line : 
          <strong>ListMembersMethod listMembersMethod= new ListMembersMethod();</strong>
  It doesn’t even go to the Exceptions block at all. Only to the finally block.</p>
  
  <p>This is the generated code by Intelij IDEA for the class <strong>ListMembersMethod</strong>:</p>
  
  <pre><code>//
  // Source code recreated from a .class file by IntelliJ IDEA
  // (powered by Fernflower decompiler)
  //
  
  package com.ecwid.mailchimp.method.v1_3.list;
  
  import com.ecwid.mailchimp.MailChimpAPIVersion;
  import com.ecwid.mailchimp.MailChimpMethod.Method;
  import com.ecwid.mailchimp.MailChimpObject.Field;
  import com.ecwid.mailchimp.method.v1_3.list.HasListIdMethod;
  import com.ecwid.mailchimp.method.v1_3.list.ListMembersResult;
  import com.ecwid.mailchimp.method.v1_3.list.MemberStatus;
  import java.util.Date;
  
  @Method(
      name = "listMembers",
      version = MailChimpAPIVersion.v1_3
  )
  public class ListMembersMethod extends HasListIdMethod&lt;ListMembersResult&gt; {
      @Field
      public MemberStatus status;
      @Field
      public Date since;
      @Field
      public Integer start;
      @Field
      public Integer limit;
  
      public ListMembersMethod() {
      }
  }
  
  
  Intelij Idea has also generated the following code for hasHasListIdMethod :
  
  //
  // Source code recreated from a .class file by IntelliJ IDEA
  // (powered by Fernflower decompiler)
  //
  
  package com.ecwid.mailchimp.method.v1_3.list;
  
  import com.ecwid.mailchimp.MailChimpMethod;
  import com.ecwid.mailchimp.MailChimpObject.Field;
  
  public abstract class HasListIdMethod&lt;R&gt; extends MailChimpMethod&lt;R&gt; {
      @Field
      public String id;
  
      public HasListIdMethod() {
      }
  }
  </code></pre>
  
  <p>The MailChimpMethod has the following code where it contains <strong>TypeToken</strong>
  :</p>
  
  <pre><code>//
  // Source code recreated from a .class file by IntelliJ IDEA
  // (powered by Fernflower decompiler)
  //
  
  package com.ecwid.mailchimp;
  
  import com.ecwid.mailchimp.MailChimpAPIVersion;
  import com.ecwid.mailchimp.MailChimpObject;
  import com.ecwid.mailchimp.MailChimpObject.Field;
  import com.google.common.reflect.TypeToken;
  import java.lang.annotation.Documented;
  import java.lang.annotation.ElementType;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.lang.annotation.Target;
  import java.lang.reflect.GenericArrayType;
  import java.lang.reflect.ParameterizedType;
  import java.lang.reflect.Type;
  
  public abstract class MailChimpMethod&lt;R&gt; extends MailChimpObject {
      private final TypeToken&lt;R&gt; resultTypeToken = new TypeToken(this.getClass()) {
      };
      @Field
      public String apikey;
  
      public MailChimpMethod() {
      }
  
      public final MailChimpMethod.Method getMetaInfo() {
          for(Class c = this.getClass(); c != null; c = c.getSuperclass()) {
              MailChimpMethod.Method a = (MailChimpMethod.Method)c.getAnnotation(MailChimpMethod.Method.class);
              if(a != null) {
                  return a;
              }
          }
  
          throw new IllegalArgumentException("Neither " + this.getClass() + " nor its superclasses are annotated with " + MailChimpMethod.Method.class);
      }
  
      public final Type getResultType() {
          Type type = this.resultTypeToken.getType();
          if(!(type instanceof Class) &amp;&amp; !(type instanceof ParameterizedType) &amp;&amp; !(type instanceof GenericArrayType)) {
              throw new IllegalArgumentException("Cannot resolve result type: " + this.resultTypeToken);
          } else {
              return type;
          }
      }
  
      @Documented
      @Retention(RetentionPolicy.RUNTIME)
      @Target({ElementType.TYPE})
      public @interface Method {
          MailChimpAPIVersion version();
  
          String name();
      }
  }
  </code></pre>
  
  <p>I would really appreciate your help on this. Couldn't figure out what the fix would be.</p>