java.lang.NoClassDefFoundError: com/google/api/ads/common/lib/auth/OfflineCredentials$OAuthConfig

220 views
Skip to first unread message

kdai...@gmail.com

unread,
Mar 11, 2018, 4:15:56 AM3/11/18
to Google's DoubleClick for Publishers API Forum
I wrote simple code and faced to NoClassDefError. It seems forApi(OfflineCredentials.Api.DFP) throws this error. Could you give me ideas what can cause this problem?

    public static void main(String[] args) {

        try {

            Credential credential = new OfflineCredentials.Builder()

                    .forApi(OfflineCredentials.Api.DFP)

                    .withClientSecrets(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)

                    .build()

                    .generateCredential();

        } catch (Exception e) {

            e.printStackTrace();

        }   

    }   



Error: A JNI error has occurred, please check your installation and try again

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/api/ads/common/lib/auth/OfflineCredentials$OAuthConfig

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)

at java.lang.Class.privateGetMethodRecursive(Class.java:3048)

at java.lang.Class.getMethod0(Class.java:3018)

at java.lang.Class.getMethod(Class.java:1784)

at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)

at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)

Caused by: java.lang.ClassNotFoundException: com.google.api.ads.common.lib.auth.OfflineCredentials$OAuthConfig

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 7 more


Vincent Racaza (DFP API Team)

unread,
Mar 11, 2018, 11:53:53 PM3/11/18
to Google's DoubleClick for Publishers API Forum
Hi,

Could you confirm if you are installing the Java client library through maven? It seems that not all the dependencies were downloaded as it could not find the OAuthConfig class based on the error message. Please make sure that all the dependencies are downloaded as you can see on this guide.

Also, we recommend that you use the property file in getting the OAuth2 credentials so you won't set your credentials per code file that you will be creating.

Thanks,
Vincent Racaza, DFP API Team
Reply all
Reply to author
Forward
0 new messages