2

I'm trying to use jTwitter to get an oauth instance to twitter with my consumer key/secret and access token/secret. This is well documented in the javadoc here. I have downloaded signpost, signpost-jetty, and the jtwitter library, but after deploying and running the servlet, I get a error java.lang.NoClassDefFoundError: winterwell/jtwitter/OAuthSignpostClient Eclipse isn't complaining about the class not being there, because it is there-- I can see it in the JAR file itself, which is in my project. So, I said forget it, I'll try out OAuthScribeClient instead, but this generated a VERY SIMILAR ERROR java.lang.NoClassDefFoundError: org/scribe/oauth/Token This one confuses me even further because I have the following code in my java file, and it compiles without error or warning:

import org.scribe.oauth.Token;
Token token = new Token("myaccesstokeninfo", "accesstokensecret");

Clearly, I'm missing something very fundamental, but I am at an absolute loss as to what it may be. Thanks.

D-Nice
  • 4,772
  • 14
  • 52
  • 86

3 Answers3

2

Usually "NoClassDefFoundError" happens when you forget to copy all jar-files to your "/war/WEB-INF/lib" directory, so those libs will be unavailable from server-side.

Ilia Akhmadullin
  • 1,573
  • 1
  • 10
  • 16
  • @ilia-akhmadullin I go the same problem, but my jar files are in the /war/web-inf/lib folder. I cannot resolve this issue. Are there any other reasons why this might happen. Thank you. – Kervin Ramen Apr 17 '11 at 06:33
1

Xo4yHaMope is probably right.

If you're working from Eclipse but running using a web container, then your runtime classpath might be different from your project classpath - which can cause this error.

Ben Winters
  • 504
  • 1
  • 6
  • 7
0

In order to complete Ben Winters answer what I actually did and worked is add the jar in the libs folder within the project

see also here about folder hierarchy.

When you do this eclipse will normally add the jar to the android dependencies before launching the application. What I realise is that adding a jar in the build path will make classes available only during the build

kon psych
  • 626
  • 1
  • 11
  • 26