Friday, 24 June 2016

NoClassDefFoundError

Hi,

I started to develop an application using the adwords api. I managed everything so far (test accounts, oauth2 ...) and have my auth and refresh token. Now I'm trying to get the customer id (to see, whether the service works or not):

    private static AdWordsSession createAdWordsSession(String clientId, String clientSecret,
            String refreshToken, String developerToken, String userAgent) throws OAuthException,
            ValidationException {
        // Create a valid OAuth2 credential without using a properties file.
        Credential credential = new OfflineCredentials.Builder()
                .forApi(Api.ADWORDS)
                .withClientSecrets(clientId, clientSecret)
                .withRefreshToken(refreshToken)
                .build()
                .generateCredential();

        // Create a new AdWordsSession without using a properties file.
        return new AdWordsSession.Builder()
                .withDeveloperToken(developerToken)
                .withUserAgent(userAgent)
                .withOAuth2Credential(credential)
                .build();
    }

and running into the following exception:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.api.ads.common.lib.auth.OfflineCredentials$Api
at com.xx.web.GoogleAuth.createAdWordsSession(GoogleAuth.java:137)
at com.xx.web.GoogleAuth.getCampaigns(GoogleAuth.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 36 more

Im using the latest API 2.16. Any idea, why?

TIA,
Bert

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/0f2b8c62-f838-4bd5-8820-6d0ca000952e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment