简体   繁体   中英

java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64 when trying to create CommonsHttpOAuthConsumer

EDIT:

public static void main(String[] args)throws Exception {
    // TODO Auto-generated method stub
    System.out.println("debug1");
    CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer("key","secret");
         System.out.println("debug2");
...}

hi when i try to run this script i get this response:

debug1

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64

at oauth.signpost.signature.OAuthMessageSigner.<init>(OAuthMessageSigner.java:37)

at oauth.signpost.signature.HmacSha1MessageSigner.<init>(HmacSha1MessageSigner.java:30)

at oauth.signpost.AbstractOAuthConsumer.<init>(AbstractOAuthConsumer.java:65)

at oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.<init>(CommonsHttpOAuthConsumer.java:30)

at mein.tester.main(tester.java:21)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

... 5 more

Line 21 is the line before

         System.out.println("debug2");

Well i can easily compile the code in eclipse and i added 2 Signpost librabrys and also common-codec.jar as external library as i read in another post.. however, how do i make it available on runtime?(i did like in the post "add it to WEB-INF/lib " -> i created that folder and added the jar -i also tryed the defaultoauthconsumer -> same error

Right click on the jar and choose "add to build path"? I don't think the ide will automatically add it to your classpath unless you tell it to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM