Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Sendgrid Java Not working in Maven

Writer Andrew Mclaughlin

I am using in my app. When I tried to run a sendgridexample.java its causing error InvocationTargetException and the root cause is

java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClientBuilder com.sendgrid.SendGrid.<init>(SendGrid.java:80) I am using maven. Is there anyone tried this in maven. I tried reaching the sendgrid support team but still didn't get any update regarding this. Can any one tell what is wrong with my code. Thanks in advance.

SendGrid sendgrid = new SendGrid("API_KEY");
SendGrid.Email email = new SendGrid.Email();
email.addTo("[email protected]");
email.setFrom("[email protected]");
email.setSubject("Hello World");
email.setText("My first email with SendGrid Java!");
try { SendGrid.Response response = sendgrid.send(email); System.out.println(response.getMessage());
}
catch (SendGridException e) { System.err.println(e);
}
1

1 Answer

Yes, I have found a solution. Go to . Copy the two java file[SendGrid.java and SendGridException.java] and create a folder com.sendgrid in your application and paste these two java file inside that folder. Then go to . Copy all the dependency for these two java file and paste in your pom.xml file. It will work fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.