Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractResponseHandler Error #202

Closed
devourer17 opened this issue Jun 21, 2017 · 1 comment
Closed

AbstractResponseHandler Error #202

devourer17 opened this issue Jun 21, 2017 · 1 comment
Labels
status: help wanted requesting help from the community type: question question directed at the library

Comments

@devourer17
Copy link

devourer17 commented Jun 21, 2017

Issue Summary

I am using sendgrid inside a network secured by firewall. I consume several external api from my java application. I set the proxy settings as below to connect to the external APIs. I'm using sendgrid-java:4.0.0, java-http-client:4.0.0, (Apache)HttpComponents(4.5.2), Java 1.8
Though I'm receiving the mail; I'm getting this exception:

 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/AbstractResponseHandler
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at com.sendgrid.Client.getResponse(Client.java:127)
	at com.sendgrid.Client.executeApiCall(Client.java:284)
	at com.sendgrid.Client.post(Client.java:192)
	at com.sendgrid.Client.api(Client.java:310)
	at com.sendgrid.SendGrid.makeCall(SendGrid.java:94)
	at com.sendgrid.SendGrid.api(SendGrid.java:113)

My code goes like this:

                Mail mail = new Mail();
		Email fromEmail = new Email(), toEmail = new Email();
		Content content = new Content();
		Personalization personalization = new Personalization();
		fromEmail.setName(contactName);
		fromEmail.setEmail(fromEmail);
		toEmail.setEmail(toEmail);
		content.setType("text/html");
		content.setValue(contentData);
		personalization.addTo(toEmail);
		mail.setFrom(fromEmail);
		mail.setSubject(subject);
		mail.addContent(content);
		mail.setReplyTo(toEmail);
		mail.addPersonalization(personalization);

		CloseableHttpClient httpclient = HttpClients.custom().useSystemProperties().setProxy(new HttpHost(httpProxy, port)).build();
		Client client = new Client(httpclient);
		SendGrid sg = new SendGrid(apiKey, client);

		//SendGrid sg = new SendGrid(apiKey);
		
		Request requestEmail = new Request();
		try {
			requestEmail.setMethod(Method.POST);
			requestEmail.setEndpoint("mail/send");
			requestEmail.setBody(mail.build());
			
			Response response = sg.api(requestEmail);
			System.out.println("Email Status: " + response.getStatusCode());
		} catch (IOException ex) {
			System.out.println(ex.getMessage());
			ex.printStackTrace();
		}
@thinkingserious thinkingserious added status: help wanted requesting help from the community type: question question directed at the library labels Jun 21, 2017
@thinkingserious
Copy link
Contributor

Hello @devourer17,

It looks like you are missing this class: https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/AbstractResponseHandler.html

Could you please upgrade java-http-client to 4.1.0? With these dependencies.

I hope that helps!

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

2 participants