source code and compiled .jar do not appear to be the same in awapi_java_lib_1.0.1

12 views
Skip to first unread message

robertjw

unread,
Jul 24, 2008, 6:46:18 AM7/24/08
to AdWords API Forum
We were trying to use the source code of the class:
com.google.api.adwords.v12.AccountServiceSoapBindingStub

and noticed that it has this class definition:

public class AccountServiceSoapBindingStub extends
org.apache.axis.client.Stub implements
com.google.api.adwords.v12.AccountInterface

Compiling and using this class gives all sort of problems, esp this
type:
java.lang.ClassCastException:
com.google.api.adwords.v12.AccountServiceSoapBindingStub ...


This error does not occur when we use the adwords-api-1.0.1.jar
provided in the same distribution, so we decompiled the
AccountServiceSoapBindingStub.class and found that its definition was
different than the source code. In particular it has this definition:
public class AccountServiceSoapBindingStub extends Stub implements
AccountInterface, AdWordsService
(note that it implements AdWordsService)

Is there a reason for this difference? If the source and compiled code
are not the same, it makes debugging code very difficult.

Thanks



AdWords API Advisor

unread,
Jul 25, 2008, 12:12:13 PM7/25/08
to AdWords API Forum
Hello Robert,

Hmmm, I'm not positive about mis-matches between the compiled .jar
and the provided source (and can ask a colleague about that if need
be), but I've seen that sort of error you describe when there is a
version mismatch between the version of the API (11 or 12) you specify
that you're using in your credentials and the corresponding version of
API whose support libraries you're import-ing into your code. If
you're not specifying an explicit version of the API in your
credentials (either via a "version=1X" line in your ~/
adwords.properties file or via the AdWordsUser() constructor) then
it's going to default to the earliest supported version, 11.

Can you check to make sure your import-ed libraries match the version
in your credentials?

Cheers,
-Jeff Posnick, AdWords API Team

robertjw

unread,
Jul 27, 2008, 11:01:27 AM7/27/08
to AdWords API Forum
Our code does explicitly state the API version when we create the
AdWordsUser. We create AdWordsUser like the following:

Map credentials = new HashMap();
credentials.put("applicationToken", apptkn);
credentials.put("developerToken", dvltkn );
credentials.put("useragent", usragt );
credentials.put("email", email );
credentials.put("password", passwd );
credentials.put("version", "v12");
AdWordsUser myMCC = new AdWordsUser( credentials );

Furthermore this code DOES work with the compiled version 12 api
(adwords-api-1.0.1.jar). We get the classpath error when we try and
use the source (compiling it ourselves).
Line 172 of the source code of the class:
com.google.api.adwords.lib.BaseCredentials is:

((AdWordsService) obj).setServiceAccountant(new
ServiceAccountant((Stub) obj));

Which requires that the obj in question be an instance of
AdWordsService
obj in our case is an instance of:
com.google.api.adwords.v12.AccountServiceSoapBindingStub
Which I believe is NOT an instance AdWordsService (in the source
code).

However when we decompiled the AccountServiceSoapBindingStub.class
extracted from the binary source (.jar) we found that this class
implements com.google.api.adwords.v12.AccountService (i.e. is an
instance of AccountService)

Thanks


On Jul 25, 6:12 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:

AdWords API Advisor

unread,
Jul 29, 2008, 3:56:29 PM7/29/08
to AdWords API Forum
Hello Robert,

Thanks for your detailed info. We're looking into this further to see
exactly what might account for this discrepancy.

Cheers,
-Jeff Posnick, AdWords API Team


AdWords API Advisor

unread,
Jul 31, 2008, 1:36:40 PM7/31/08
to AdWords API Forum
Robert,

Can you try using ant build that is shipped with the project
(build.xml), to compile the sources? The build should automatically
generate two jars, regular one and loner.

--Stan

On Jul 27, 11:01 am, robertjw <baClie...@gmail.com> wrote:

Achal Rastogi

unread,
Aug 31, 2008, 4:49:34 AM8/31/08
to AdWords API Forum
I compiled the source on my own and am successfully using it right
now. I faced similar issues, quick summary below:

1) Problem is this line : ((AdWordsService)
obj).setServiceAccountant(new ServiceAccountant((Stub) obj));

this is line 173 of BaseCredentials.java - if you are not aware of
aspectj you might think that this is a bug and there is no such method
as setServiceAccountant on any of the stubs.

setServiceAccountant is defined on each stub using AspectJ ( look in
src/com/google/api/adwords/lib/WebServiceWrapper.aj for more
details) , also look at iajc target @ build.xml

2) I was facing similar issues because i was using loner jar ( i
already have other dependencies in my classpath), the full jar has all
dependencies so even aspectjrt.jar is part of it and if you built the
full jar on your own and use it , you will not face this issue. But
very few people would want to use full jar because of other
dependencies in it and higher chances of breaking xml parsing,
conflicting with jar files of tomcat, resin etc etc ( i tried and
immediately gave up :-) )

3) So other then loner jar i added aspectjrt.jar in my classpath and
everything works good now.

It was hard to figure this out and it is expected to mention these
kinda non-trivial run-time dependencies in the release notes.


achal....@gmail.com









On Jul 31, 10:36 am, AdWords API Advisor
Reply all
Reply to author
Forward
0 new messages