Reputation: 53
I am using twitter4j 4.0.2
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(this.consumerKey);
cb.setOAuthConsumerSecret(this.consumerSecret);
cb.setOAuthAccessToken(this.accessToken);
cb.setOAuthAccessTokenSecret(this.accessTokenSecret);
this.twitter = new TwitterFactory(cb.build()).getInstance();
here the error i am getting when i run this
Exception in thread "main" java.lang.NoClassDefFoundError: com/squareup/okhttp/OkHttpClient
at twitter4j.AlternativeHttpClientImpl.prepareClient(AlternativeHttpClientImpl.java:120)
at twitter4j.AlternativeHttpClientImpl.getConnection(AlternativeHttpClientImpl.java:60)
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:88)
at twitter4j.AlternativeHttpClientImpl.handleRequest(AlternativeHttpClientImpl.java:104)
at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
at twitter4j.HttpClientBase.get(HttpClientBase.java:71)
at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:128)
at twitter4j.TwitterImpl.verifyCredentials(TwitterImpl.java:545)
how to get this working??
Upvotes: 0
Views: 982
Reputation: 4781
It seems that the version 4.0.2 at least has a dependency on okhttp. This is only true for the twitter4j-spdy-support package and not the other in twitter4j.
The pom.xml has:
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>1.5.1</version>
</dependency>
If you want to use the twitter4j-spdy-support then you need to have the okhttp JAR file(s). If you use maven the running your app with maven will solve the problem.
And the other option is not to use the spdy support and not have it in the classpath.
Upvotes: 1