I'm getting a mysterious error when I try to execute Google's authentication example code which I got from here: https://developers.google.com/google-apps/calendar/instantiate
I'm not even sure which information is relevant, so I'll start from the beginning. I copied and pasted the code directly. The only changes I made were:
- I plugged my own authentication info in where it was required
- I created a main method.
- I imported some additional classes, including
com.google.api.client.http.UrlEncodedContent
My modified version is here: https://gist.github.com/Glank/cac68a658a9b1aeb393c
I build and run the code using the following maven commands:
mvn clean install
mvn exec:java -Dexec.mainClass="org.mu.TestServlet"
My pom dependencies are here: https://gist.github.com/Glank/50fe98a9575e10df6a68
The code builds and executes with no issues other than a few encoding warnings. It gives me a link. I go, give myself permission to access the data and am redirected to a uri with a code parameter. I copy and paste the parameter into standard input after the prompt, "What is the authorization code?" Then suddenly, I get the following exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoSuchMethodError: com.google.api.client.http.UrlEncodedContent: method <init>()V not found
at com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.executeUnparsed(AccessTokenRequest.java:444)
at com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.execute(AccessTokenRequest.java:470)
at org.mu.TestServlet.setUp(TestServlet.java:54)
at org.mu.TestServlet.main(TestServlet.java:23)
I have looked at the source code for URLEncodeContent and AccessTokenRequest:
- AccessTokenRequest source code: https://code.google.com/p/google-api-java-client/source/browse/google-api-client/src/main/java/com/google/api/client/auth/oauth2/draft10/AccessTokenRequest.java?r=8d2015927d8506e63e349129b093c033e074cbdd
- URLEncodedContent source code: https://code.google.com/p/google-api-java-client/source/browse/google-api-client/src/main/java/com/google/api/client/http/UrlEncodedContent.java?r=8d2015927d8506e63e349129b093c033e074cbdd
No constructor is implemented for UrlEncodedContent. From what I've read this exception is thrown when the default constructor is being called but another constructor is implemented: method init()v not found
Any help would be greatly appreciated.