twitter4j v2.2.4 NoClassDefFoundError:
in
Contributed Library Questions
•
2 years ago
Hi, Iv been wrestling with this library for some hours now.
From
this post I can see that v2.2.2 seemed to work so I copied the example provided there.
Here it is for quick reference
- import twitter4j.conf.*;
- import twitter4j.internal.async.*;
- import twitter4j.internal.org.json.*;
- import twitter4j.internal.logging.*;
- import twitter4j.json.*;
- import twitter4j.internal.util.*;
- import twitter4j.management.*;
- import twitter4j.auth.*;
- import twitter4j.api.*;
- import twitter4j.util.*;
- import twitter4j.internal.http.*;
- import twitter4j.*;
- import twitter4j.internal.json.*;
- String ConsumerKey = "*************************************************************";
- String ConsumerSecret = "*************************************************************";
- String oauth_token = "**********************************************************************";
- String oauth_token_secret = "*************************************************************";
- String msg = "Test post via P55 T4J";
- boolean sent;
- TwitterFactory tf;
- void setup() {
- size(200,200);
- background(255);
- sent = false;
- ConfigurationBuilder cb = new ConfigurationBuilder();
- cb.setDebugEnabled(true)
- .setOAuthConsumerKey(ConsumerKey)
- .setOAuthConsumerSecret(ConsumerSecret)
- .setOAuthAccessToken(oauth_token)
- .setOAuthAccessTokenSecret(oauth_token_secret);
- tf = new TwitterFactory(cb.build());
- }
- void draw() {
- if(sent) background(100);
- }
- void mousePressed() {
- Twitter twitter = tf.getInstance();
- try {
- Status st = twitter.updateStatus(msg + " " + getDateTime());
- println("Successfully updated the status to [" + st.getText() + "].");
- sent = true;
- }
- catch (TwitterException e) {
- println(e.getStatusCode());
- }
- }
- String getDateTime() {
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
- Date date = new Date();
- return dateFormat.format(date);
- }
When I run the sketch an click on the mouse I get this error
java.lang.NoClassDefFoundError: com/google/appengine/api/urlfetch/HTTPRequest
I found in
this forum that a possible solution is to remove twitter4j-appengine-2.2.4.jar from the library, so I did. The original erros is gone now and instead I get a 401 on the console.
From what I
read here the error stems from an authentication error.
Any ideas?
Thank you
1