1

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:

  1. I plugged my own authentication info in where it was required
  2. I created a main method.
  3. 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:

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.

Community
  • 1
  • 1
ejk314
  • 381
  • 1
  • 11

1 Answers1

0

I don't know for sure what was causing the error, but I managed to get it working after starting from scratch and ignoring that particular code example. I assume the issue was with miss-matched versions of dependencies in my pom - now they are all version 1.15.1-rc. Anyways, here's my working code if anyone else has similar problems:

https://github.com/Glank/MinimalGoogleCalendarWebAccess

ejk314
  • 381
  • 1
  • 11