向Dropbox发送请求

时间:2012-05-25 13:17:37

标签: java tomcat servlets dropbox

我在tomacat中执行我的servlet时遇到此错误....

代码...用于发送数据......

String result= URLEncoder.encode(oauth_token , "UTF-8")+"&";     





        PostMethod get = new PostMethod("https://api.dropbox.com/1/oauth/request_token");
        get.addParameter("oauth_consumer_key", "fm5qq8panuw0rnm" );
        get.addParameter("oauth_nonce",String.valueOf(nonce));
        get.addParameter("oauth_signature_method", "PLAINTEXT");
        get.addParameter("oauth_signature", result);
        get.addParameter("oauth_timestamp",String.valueOf(timestamp.getTime()/1000));
        get.addParameter("oauth_token", "z3d00yk6qwh2eui");


        int status= client.executeMethod(get);   

///////////////////////////////

HTTP状态500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class Ser
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
root cause

java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
    java.lang.Class.getDeclaredConstructors0(Native Method)
    java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
    java.lang.Class.getConstructor0(Class.java:2714)
    java.lang.Class.newInstance0(Class.java:343)
    java.lang.Class.newInstance(Class.java:325)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
root cause

java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    java.lang.Class.getDeclaredConstructors0(Native Method)
    java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
    java.lang.Class.getConstructor0(Class.java:2714)
    java.lang.Class.newInstance0(Class.java:343)
    java.lang.Class.newInstance(Class.java:325)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.

我正在尝试向dropbox发送post请求以获取request_token但是在执行我的servlet期间我遇到了这样的错误..同时通过consle main()函数执行相同的代码...我得到了正确的结果但是同样不是来自servlet

1 个答案:

答案 0 :(得分:0)

您正在申请令牌 的PostMethod( “https://api.dropbox.com/1/oauth/request_token”);

还要将令牌作为参数传递?

get.addParameter(“oauth_token”,“z3d00yk6qwh2eui”);