Run-time error running DFP API Java Libraries

316 views
Skip to first unread message

DCZ

unread,
Nov 7, 2012, 1:48:18 PM11/7/12
to google-doubleclick...@googlegroups.com
Hello,

I've compile the DFP API Java client libraries v201208 on Fedora 16, Java version 1.7.0_09 (icedtea).
I seem to be getting run-time errors running the GetAllNetworks program with the following command:

    java dfp/axis/v201208/GetAllNetworks


Here is the run-time error I am getting:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/api/ads/common/lib/client/AdsSession
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
        at java.lang.Class.getMethod0(Class.java:2685)
        at java.lang.Class.getMethod(Class.java:1620)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:492)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:484)
Caused by: java.lang.ClassNotFoundException: com.google.api.ads.common.lib.client.AdsSession
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 6 more

Any idea how to resolve these errors?

Thanks,
DZ

Adam Rogal (DFP API Team)

unread,
Nov 7, 2012, 1:55:13 PM11/7/12
to google-doubleclick...@googlegroups.com
Hi,

Make sure you include the dependency jars in your classpath. Take a look at this wiki entry:


If you haven't yet, I would also recommend looking into using Maven, which would make your dependency management much easier.

Thanks,
Adam Rogal, DFP API Team

DCZ

unread,
Nov 7, 2012, 2:09:54 PM11/7/12
to google-doubleclick...@googlegroups.com
Adam,

I'm compiling WITH Maven, according to the Quick Start instructions:
  1. Download and extract example project (e.g. dfp-axis-examples-1.5.0.tar.gz) from downloads
  2. Extract project and cd into dfp-examples/dfp-axis/ (or similar)
  3. Edit src/main/resources/ads.properties
  4. $ mvn -X compile
  5. $ mvn -X exec:java -Dexec.mainClass="dfp.axis.v201204.GetAllNetworks"
 The pom.xml file already contains all of the dependencies. Once I compile, which goes through without errors, all I did was cd into the target/classes directory and ran the application with the following command:

java dfp/axis/v201208/GetAllNetworks

The application produced the run-time errors above.
What am I missing here?

Thanks,
-DZ

DZ

unread,
Nov 7, 2012, 2:13:18 PM11/7/12
to google-doubleclick...@googlegroups.com
Slight correction:
I've downloaded version dfp-axis-examples-1.11.0.tar.gz.
I'm compiling v201208, and not v201204.

DZ

unread,
Nov 7, 2012, 3:15:31 PM11/7/12
to google-doubleclick...@googlegroups.com
Is there an "out-of-the-box" solution in C/C++ that is platform independent (e.g. runs on Linux)?

Adam Rogal (DFP API Team)

unread,
Nov 7, 2012, 3:41:09 PM11/7/12
to google-doubleclick...@googlegroups.com
Hi DZ,

Allow me to clear up some confusion. When you use maven to compile, you have to also use it to execute. While you can go into the directory where the class is located and execute java on the class, it won't have any dependencies on the classpath.

What maven is doing under the covers is generating a largest list of dependency locations and including them in a -cp flag. While you could do the same, there isn't any real benefit.

Please execute you command using: mvn -X exec:java -Dexec.mainClass="dfp.axis.v201204.GetAllNetworks"

If you are worried about how you will eventually be calling your java from your environment, there are lots of maven plugins out there can help you deploy runnable jars. Take a look here: http://stackoverflow.com/questions/2022032/building-a-runnable-jar-with-maven-2

Thanks,
Adam Rogal, DFP API Team

DZ

unread,
Nov 7, 2012, 4:00:26 PM11/7/12
to google-doubleclick...@googlegroups.com
That makes a lot of sense. I'm new to Maven, so I guess I was very confused how it is used to execute the java app. Thank you for the clarification.

-DZ

DZ

unread,
Nov 7, 2012, 4:05:13 PM11/7/12
to google-doubleclick...@googlegroups.com
BTW, are there any plans to release a platform independent C/C++ client library? For those of us that are utilizing the API for performance-driven applications, PHP, Ruby and Python would not be the best approach. That only leaves Java and .NET, and only the former can run on a Linux platform. A C/C++ library would be the most universal solution because the compiled binary application can be integrated with any of the other libraries. 

Thanks,
-DZ

Adam Rogal (DFP API Team)

unread,
Nov 7, 2012, 11:03:02 PM11/7/12
to google-doubleclick...@googlegroups.com
Hi DZ,

There are no plans at this time to release a C/C++ client library. I will forward along your request to the rest of the team.

Thanks,
Adam Rogal, DFP API Team
Reply all
Reply to author
Forward
0 new messages