You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because sendgrid/java-http-client depends on org.apache.httpcomponents/httpcore, this library is necessary under google appengine in order to stay under socket connection quotas: https://github.com/sendgrid/sendgrid-google-java
But it looks like that library is soon to be very out of date with the latest sendgrid apis. It would be great if java-http-client could remove that dependency and just use the built in java http connection apis directly so that the official sendgrid-java library would work in all scenarios.
We have the org.apache.httpcomponents/httpcore dependency because the java http connection apis do not support PATCH. Do you know of a work around to this? Is there another http library that would achieve your results?
The background regarding appengine is that it's a bit of a strange beast and java code there runs on a google-modified jdk. That jdk whitelists certain classes and has custom implementations of others so that code runs safely from multiple users without interfering with each other.
Google does some special magic to HttpURLConnection so those calls run in their sandbox. That magic doesn't exist for the apache http implementation, so appengine does a socket connection instead to safely exit the sandbox. This works fine, but google imposes a limit on the number of socket connections allowed per project... so if you send a high volume of email you can blow that limit. Once you hit that quota you're pretty much SOL, as any further calls that use socket connections (be they sending emails or connections to a database) will fail until the quota resets the next day. Not fun.
Anyhow, as long as the older sendgrid-google-java code still works, it's a fine stopgap measure for us to keep using it... but if the sendgrid apis it talks to become deprecated we'll need to have an alternative that doesn't use apache httpcore at that point.
Thanks for the detailed response! We are not deprecating the v2 version of our mail send endpoint, so you are good there.
The first link is something I have not tried, but the second does not work in my tests.
In September, Java will get an update where the HTTP core library will support PATCH. I'm hoping this will be a solid solution. We were able to use core HTTP libraries on all the other 6 languages we support and were quite surprised to run into the PATCH issue when we tried to remove the Apache dependency on this library :(
I'll leave this issue open for further investigation, so yes, your stop gap solution should be fine. Just please be careful when making any updates.
I apologize for not being clear. This is an open issue. We need to actually replace the current client with the google-http-java-client. It will not be as simple as just replacing the client, I don't think. I believe the google-http-java-client probably has a different interface to the apache http client.
What is the status for this fix? I am also using App Engine and running into the same issue. I am using my own http utils in App Engine for now, but would love to use this library.
I am also curious what the status of this issue is. I just tried to create a SendGrid instance in Android and got: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier;
Hi there, I was just wondering if this issue is still being worked on as I am currently experiencing the same issue, or is there even a work around for the time being to get my Android app to send an email? Thanks
@johnnyzen As far as I know, it's not currently being worked on. The original request was to allow for better usage within Google App Engine; not Android even though a fix may impact both.
That said, interacting with SendGrid APIs that require auth is not recommended from a client/app/browser. Doing so requires potentially exposing credentials to the end user. The APIs should be invoked by a backend service which could be supporting the front-end client. What's your use case for needing this to be available on Android? There may be edge cases I'm not considering here so just trying to get some clarity.
I have already spent/wasted 2 days trying to integrate SendGrid into my app and every single time it either fails because of the:
java.lang.NoSuchFieldError: No static field INSTANCE of type org/apache/http/conn/ssl/AllowAllHostnameVerifier; #588
or the duplication of libraries, or something else. This is particularly frustrating and with the issue first reported more than 3 years ago, I couldn't find a straightforward "just works" solution as of now.
After appeasing a build exception due to More than one file was found with OS independent path 'META-INF/DEPENDENCIES' in my issue #625, I'm now also stuck with java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier
Misery loves company.
Reacted by Kes Walker, Catherine Garabedian, Prathamesh Joshi, he1ex-tG, yamanjain and Vitaliy Martynets
Activity
thinkingserious commentedon May 20, 2016
Hello @depsypher,
Thanks for the issue!
The new, supported, library can be found here: https://github.com/sendgrid/sendgrid-java/tree/v3beta, it will be out of beta in a few weeks.
I did not see anything in the https://github.com/sendgrid/sendgrid-google-java library that deals with socket connection quotas, could you please elaborate?
We have the org.apache.httpcomponents/httpcore dependency because the java http connection apis do not support PATCH. Do you know of a work around to this? Is there another http library that would achieve your results?
With Best Regards,
Elmer
depsypher commentedon May 20, 2016
Very interesting. I didn't know that about PATCH. I found a couple workarounds, but I'm not sure which is the better one:
https://java.net/jira/browse/JERSEY-639
http://stackoverflow.com/questions/25163131/httpurlconnection-invalid-http-method-patch
The background regarding appengine is that it's a bit of a strange beast and java code there runs on a google-modified jdk. That jdk whitelists certain classes and has custom implementations of others so that code runs safely from multiple users without interfering with each other.
Google does some special magic to HttpURLConnection so those calls run in their sandbox. That magic doesn't exist for the apache http implementation, so appengine does a socket connection instead to safely exit the sandbox. This works fine, but google imposes a limit on the number of socket connections allowed per project... so if you send a high volume of email you can blow that limit. Once you hit that quota you're pretty much SOL, as any further calls that use socket connections (be they sending emails or connections to a database) will fail until the quota resets the next day. Not fun.
Anyhow, as long as the older sendgrid-google-java code still works, it's a fine stopgap measure for us to keep using it... but if the sendgrid apis it talks to become deprecated we'll need to have an alternative that doesn't use apache httpcore at that point.
thinkingserious commentedon May 20, 2016
@depsypher,
Thanks for the detailed response! We are not deprecating the v2 version of our mail send endpoint, so you are good there.
The first link is something I have not tried, but the second does not work in my tests.
In September, Java will get an update where the HTTP core library will support PATCH. I'm hoping this will be a solid solution. We were able to use core HTTP libraries on all the other 6 languages we support and were quite surprised to run into the PATCH issue when we tried to remove the Apache dependency on this library :(
I'll leave this issue open for further investigation, so yes, your stop gap solution should be fine. Just please be careful when making any updates.
thinkingserious commentedon Aug 4, 2016
For reference: http://android-developers.blogspot.be/2011/09/androids-http-clients.html
thinkingserious commentedon Apr 18, 2017
Note:
Consider replacing with https://github.com/google/google-http-java-client
[-]Httpcore dependency[/-][+]Replace Httpcore dependency[/+]dougouk commentedon May 28, 2017
EDIT: nvm, I see that this is an on-going issue.
The link https://github.com/sendgrid/sendgrid-java/tree/v3beta no longer works.
Is there a fix for this?
Is the fix "replacing with https://github.com/google/google-http-java-client"?
thinkingserious commentedon May 28, 2017
Hi @dougouk,
I believe the fix is to replace the http client with the google-http-java-client. Unless the native Java client has caught up.
In any case, I've added your vote to this issue to help increase it's priority.
Thanks!
dougouk commentedon May 28, 2017
@thinkingserious
I tried replacing the http client, but it didn't fix the issue.
The SendGrid API looks for the http client, not the google-http-java-client in the code, so replacing it doesn't fix the issue.
I am actually more specifically here for the following closed issue sendgrid/sendgrid-java#127 but the issue redirects me to this thread.
All I'm trying to do is simply send an email using SendGrid on Android, but I can't due to the dependency issues
Is there a solution?
thinkingserious commentedon May 28, 2017
I apologize for not being clear. This is an open issue. We need to actually replace the current client with the google-http-java-client. It will not be as simple as just replacing the client, I don't think. I believe the google-http-java-client probably has a different interface to the apache http client.
7 remaining items
andy-trimble commentedon Jan 23, 2018
Ah, yes @thinkingserious. I completely forgot about this one. I'll take a crack at it.
thinkingserious commentedon Jan 24, 2018
Awesome!
bashoogzaad commentedon Dec 8, 2018
What is the status for this fix? I am also using App Engine and running into the same issue. I am using my own http utils in App Engine for now, but would love to use this library.
szeidner commentedon Feb 12, 2019
I am also curious what the status of this issue is. I just tried to create a SendGrid instance in Android and got:
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier;Glennmen commentedon Mar 28, 2019
Is this still being worked on? I am currently having the same issue in Android.
walker142 commentedon Apr 4, 2019
Hi there, I was just wondering if this issue is still being worked on as I am currently experiencing the same issue, or is there even a work around for the time being to get my Android app to send an email? Thanks
johnnyzen commentedon Mar 13, 2020
What is the status of this issue? Does this completely stop the library working on Android?
childish-sambino commentedon Mar 13, 2020
@johnnyzen As far as I know, it's not currently being worked on. The original request was to allow for better usage within Google App Engine; not Android even though a fix may impact both.
That said, interacting with SendGrid APIs that require auth is not recommended from a client/app/browser. Doing so requires potentially exposing credentials to the end user. The APIs should be invoked by a backend service which could be supporting the front-end client. What's your use case for needing this to be available on Android? There may be edge cases I'm not considering here so just trying to get some clarity.
vmfox commentedon Apr 26, 2020
Is there any (simple) solution at this point?
I have already spent/wasted 2 days trying to integrate SendGrid into my app and every single time it either fails because of the:
java.lang.NoSuchFieldError: No static field INSTANCE of type org/apache/http/conn/ssl/AllowAllHostnameVerifier; #588
or the duplication of libraries, or something else. This is particularly frustrating and with the issue first reported more than 3 years ago, I couldn't find a straightforward "just works" solution as of now.
digsub commentedon May 31, 2020
After appeasing a build exception due to More than one file was found with OS independent path 'META-INF/DEPENDENCIES' in my issue #625, I'm now also stuck with java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier
Misery loves company.
yamanjain commentedon Feb 22, 2022
Still the same problem in 2022 !!