简体   繁体   中英

java.lang.IllegalAccessError: tried to access method com.dropbox.core.DbxRequestUtil.addAuthHeader

I have class Dropbox.java which contains upload file function :

public class Dropbox {
        static final String ACCESS_TOKEN = "<My-Access-Token>";

    DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial", "en_US");
        static final  DbxClientV2 clientV2 = new DbxClientV2(config, ACCESS_TOKEN);

    static public void UploadFile(String path, InputStream in) throws UploadException, DbxException, IOException
    {
        clientV2.files.uploadBuilder(path).run(in);
    }
}

and call method as below

InputStream in = getInputStream();
String path="/newFileName.jpg";
Dropbox.CreateFile(path, in);

I have added these three jars for dropbox: dropbox-core-sdk-1.8.2.jar dropbox-core-sdk-2.0-beta-4.jar jackson-core-2.6.1.jar

I get this error:

java.lang.IllegalAccessError: tried to access method com.dropbox.core.DbxRequestUtil.addAuthHeader(Ljava/util/ArrayList;Ljava/lang/String;)Ljava/util/ArrayList; from class com.dropbox.core.v2.DbxRawClientV2
at com.dropbox.core.v2.DbxRawClientV2.uploadStyle(DbxRawClientV2.java:176)
at com.dropbox.core.v2.DbxFiles.upload(DbxFiles.java:8290)
at com.dropbox.core.v2.DbxFiles.access$5900(DbxFiles.java:25)
at com.dropbox.core.v2.DbxFiles$UploadBuilder.start(DbxFiles.java:8338)
at com.dropbox.core.v2.DbxFiles$UploadBuilder.start(DbxFiles.java:8304)
at com.dropbox.core.v2.DbxUploadStyleBuilder.run(DbxUploadStyleBuilder.java:29)
    at classes.Dropbox.CreateFile(Dropbox.java:30)
    at servlets.UploadServlet.doPost(UploadServlet.java:50)

...

I just removed the old jar : dropbox-core-sdk-1.8.2.jar

and used DbxClientV1 instead of DbxClient in the class

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