Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

luigiafassina's avatar
luigiafassina
Explorer | Level 4
2 months ago
Solved

Which is the java version supported by dbx sdk 7.0.0

Hi,

I would like to upgrade dropbox-core-sdk from version 4.0.1 to 7.0.0. Currently, I'm using Java JDK 8. According to the Dropbox documentation, this SDK appears to be compatible with JDK 8. However, version 7.0.0 has a dependency on jakarta.servlet-api 6.0.0, which is based on JDK 11.

I'm a bit confused: can I update the code without upgrading my JDK, or is it necessary to switch to Java 11?

Alternatively, is it possible to compile the code using JDK 11 but still run it on JDK 8?

 

 

 

  • DB-Des's avatar
    DB-Des
    2 months ago

    luigiafassina​ 

    Regarding your implementation, you can continue testing your current flow with your custom 'SessionStore' setup. If there are any compatibility issues, those would typically appear during runtime or while handling requests through your servlet environment.

    The certificate update taking effect in January isn’t related to the behavior of your integration, so it shouldn’t impact your current testing.

5 Replies

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 months ago

    Hi luigiafassina​ 

    Because version 7.0.0 has a dependency on jakarta.servlet-api 6.0.0 (which requires Java 11 or higher), you will need to use Java 11 (or higher) to compile and run your project with SDK version 7.0.0.

    It is not possible to compile the SDK with JDK 11 and then run it on JDK 8, as Java does not support running code that depends on APIs from a newer JDK on an older JDK.

  • luigiafassina's avatar
    luigiafassina
    Explorer | Level 4
    2 months ago

    Thanks for your answer.

    One more question to solve my doubts..

    This is the only place in my code where I need jakarta.servlet.

    private DbxSessionStore getSessionStore(final HttpServletRequest request) {
        HttpSession session = request.getSession(true);
        String sessionKey = "dropbox-auth-csrf-token";
        return new DbxStandardSessionStore(session, sessionKey);
    }

    I created a custom CustomDbxSessionStore class that implements DbxSessionStore but still uses javax.servlet.http.HttpSession.

    import com.dropbox.core.DbxSessionStore;
    import javax.servlet.http.HttpSession;
    
    /**
    * Custom implementation of DbxSessionStore that uses javax.servlet instead of jakarta.servlet
    */
    public class CustomDbxSessionStore implements DbxSessionStore {
    
    private final HttpSession session;
    private final String sessionKey;
    
    public CustomDbxSessionStore(HttpSession session, String sessionKey) {
    this.session = session;
    this.sessionKey = sessionKey;
    }
    
    @Override
    public String get() {
    return (String) session.getAttribute(sessionKey);
    }
    
    @Override
    public void set(String value) {
    session.setAttribute(sessionKey, value);
    }
    
    @Override
    public void clear() {
    session.removeAttribute(sessionKey);
    }
    }

    and I change the getSessionStore(..) method for using this class

    private DbxSessionStore getSessionStore(final HttpServletRequest request) {
        HttpSession session = request.getSession(true);
        String sessionKey = "dropbox-auth-csrf-token";
        return new CustomDbxSessionStore(session, sessionKey);
    }

    It looks like this will allow me to use JDK 8 at runtime, even with the updated SDK.

    Dropbox has authenticated me and allows me to import my files. Can you spot any potential issues? Can you suggest some tests to see if something isn't working? My app asks for permission from Dropbox, then imports the files, and if anything changes in Dropbox, it receives notifications and manages them.

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 months ago

    luigiafassina​ 

    We’re not able to assess whether there may be issues in your specific implementation, and we can’t make any guarantees about how your code will behave.

    If you run into a specific error or unexpected behavior while using the Dropbox API or the official Java SDK, please share the request and response details (excluding any sensitive data), and we’ll be happy to take a look.

  • luigiafassina's avatar
    luigiafassina
    Explorer | Level 4
    2 months ago

    Looking the documentation https://github.com/dropbox/dropbox-sdk-java I see that "The current release of Dropbox SDK Java supports Java 8+" and it is referred to sdk 7.0.0.
    Given that my server is running JDK 1.8, what steps should I follow to properly use this SDK in my environment?

    I don't need to compile the sdk - I just need to use the SessionStore in the following flow

    // V2 api /oauth2/token
    DbxWebAuth webAuth = new DbxWebAuth(reqConfig, appInfo);

    DbxAuthFinish authFinish = webAuth.finishFromRedirect(redirectUri, sessionStore, params);

    FullAccount accountInfo = getDropboxClientInstance().getCurrentAccount(authFinish.getAccessToken());

    My goal is to retrieve the AuthorizationToken and verify wheter the user is authorized.

    At the moment, with a custom SessionStore implementation that still imports javax.servlet, should I already notice if some flows don't work? Or should I wait until January to be sure that it works?

    thanks

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 months ago

    luigiafassina​ 

    Regarding your implementation, you can continue testing your current flow with your custom 'SessionStore' setup. If there are any compatibility issues, those would typically appear during runtime or while handling requests through your servlet environment.

    The certificate update taking effect in January isn’t related to the behavior of your integration, so it shouldn’t impact your current testing.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!