twilio / twilio-java

A Java library for communicating with the Twilio REST API and generating TwiML.
MIT License
492 stars 429 forks source link

NoSuchMethodError when creating Verification #613

Closed tuddman closed 3 years ago

tuddman commented 3 years ago

Not sure if it's something on my end, but unchanged code which I've tested and confirm does work with version 7.54.2 subsequently does not work after upgrading twilio-java library version to anything higher.

clojure equivalent of

    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Verification verification = Verification.creator(
                "VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "+15017122661",
                "sms")
            .create();

        System.out.println(verification.getSid());
    }

now does not work (after upgrading library version)

Note that many issues can be resolved by updating to the latest version.

This issue appears to have been introduced in recent version(s).

Known to work: 7.54.2

Tested, and broken: 7.55.0, 8.0.0, 8.1.0, 8.2.0, 8.3.0, 8.4.0, 8.5.0, 8.5.1

Exception/Log

java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultRedirectStrategy.<init>([Ljava/lang/String;)V
    at com.twilio.http.HttpClient.<init>(HttpClient.java:19)
    at com.twilio.http.NetworkHttpClient.<init>(NetworkHttpClient.java:46)
    at com.twilio.http.NetworkHttpClient.<init>(NetworkHttpClient.java:35)
    at com.twilio.http.TwilioRestClient$Builder.build(TwilioRestClient.java:139)
    at com.twilio.Twilio.buildRestClient(Twilio.java:204)
    at com.twilio.Twilio.getRestClient(Twilio.java:180)
    at com.twilio.base.Creator.create(Creator.java:40)

Technical details:

thinkingserious commented 3 years ago

Hello @tuddman,

Based on your exception/log, it looks like there may be a dependency issue with org.apache.httpcomponents.httpclient. Could you please try the fix here and let us know if that works? Thanks!

With best regards,

Elmer

tuddman commented 3 years ago

Yep. Explicitly adding org.apache.httpcomponents.httpclient version 4.5.12 fixed it. now works with version 8.5.1

Thanks! And apologies for not having found the other issue before posting.

ayubjamal95 commented 2 years ago

Hello @tuddman,

Based on your exception/log, it looks like there may be a dependency issue with org.apache.httpcomponents.httpclient. Could you please try the fix here and let us know if that works? Thanks!

With best regards,

Elmer

I'm using twilio connector for Wso2 and I'm facing a similar issue when I deploy the. car file on micro Integrator runtime, however when I run it on embedded server that comes with integration studio things work pretty fine. any solution to that?

childish-sambino commented 2 years ago

@ayubjamal95 Please open a new issue as closed issues are not tracked as closely.