title: SendGrid - NoClassDeffoundError using sendgrid-java.jar
body: <p>I am using SendGrid for the first time. I have looked at other questions on SO, in this regard, but none worked for me. </p>
  
  <p>I am using Eclipse and Amazon Web Services - Lambda.
  The library i am using is <a href="https://github.com/sendgrid/sendgrid-java" rel="nofollow noreferrer">https://github.com/sendgrid/sendgrid-java</a></p>
  
  <p>My scenario is, i am using a Lambda function to send emails to users who have opted for email communication. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>                        Email email = new Email();
                          email.addTo(DEV_TO_EMAIL);
                          email.addToName("XXXXX");
                          email.setFrom(DEV_FROM_EMAIL);
                          email.setSubject("XX");
                          email.setText("sms_message");
  
                          try {
                              sendgrid.send(email);
                          } catch (SendGridException e) {
                              e.printStackTrace();
  
                              if(DEBUG)
                                  logger.log("Exception while sending Email");
                          }
  </code></pre>
  
  <p>Here is the Exception:</p>
  
  <pre><code>    Could not initialize class 
  
  org.apache.http.impl.conn.ManagedHttpClientConnectionFactory: java.lang.NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory at 
  
  org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.&lt;init&gt;(PoolingHttpClientConnectionManager.java:493) at 
  
  org.apache.http.impl.conn.PoolingHttpClientConnectionManager.&lt;init&gt;(PoolingHttpClientConnectionManager.java:149) at 
  
  org.apache.http.impl.conn.PoolingHttpClientConnectionManager.&lt;init&gt;(PoolingHttpClientConnectionManager.java:138) at 
  
  org.apache.http.impl.conn.PoolingHttpClientConnectionManager.&lt;init&gt;(PoolingHttpClientConnectionManager.java:114) at 
  
  org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726) at 
  
  com.sendgrid.SendGrid.&lt;init&gt;(SendGrid.java:71) at 
  
  xx.LambdaFunction.handleRequest(LambdaFunction.java:183) at 
  
  xx.LambdaFunction.handleRequest(LambdaFunction.java:1)
  </code></pre>
  
  <p>I tried to follow this suggestion on SO, <a href="https://stackoverflow.com/questions/30284213/sendgrid-java-not-working-in-maven">Sendgrid Java Not working in Maven</a>, but it resulted in the same error as well.</p>
  
  <p>Any suggestions on what to do? Let me know if you need anything else..</p>