0

I need help with CalendarQuickstart for java. I have followed the java quickstart steps except using gradle as we won't be using it.

When, I run the file it gives the following error:

Exception in thread "main" java.lang.NoSuchMethodError: 'boolean com.google.api.client.http.HttpTransport.isMtls()'
at com.google.api.services.calendar.Calendar$Builder.chooseEndpoint(Calendar.java:6974)
at com.google.api.services.calendar.Calendar$Builder.<init>(Calendar.java:7007)
at calendarquickstart.CalendarQuickstart.main(CalendarQuickstart.java:71)
C:\Users\User\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\User\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:94: Java returned: 1
BUILD FAILED (total time: 2 seconds)

My line 71:

        Calendar service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
            .setApplicationName(APPLICATION_NAME)
            .build();

Java Quickstart steps and source code: link

The libraries I've imported:

enter image description here

I'm using Netbeans 12.4 and Java JDK 16. The program runs on the other laptop without error. I also tried to look for answer online, they said something about changing POM.xml file but I could not find it anywhere. The java project was created with Ant not gradle or maven. Hope this info helps, and thank you for helping me as I've been stuck for hours with this error.

lance2k
  • 357
  • 1
  • 4
  • 14

1 Answers1

1

You have imported many libraries in different versions.

When you do that and assuming the different versions of a library define the same package/classes names, only one will be loaded and there's no guarantee of which one.

This often create a mess as for instance a method added on later version of the library will not be available if a former version has been loaded first.

Bottom line: remove all libraries duplicate, keep only one version of each library (probably the latest but that might depends what each other library is depending on, that why dependency management tool exists by the way..).

Edit: on your case the issue is likely because of the 3 google-http-client libraries you have imported.

Gaël J
  • 11,274
  • 4
  • 17
  • 32
  • ok, will try it now. It's just strange because it runs well on the other laptop. – lance2k Aug 09 '21 at 10:49
  • Thanks it works, its just a little bit strange as it works well on the other laptop without removing this extra libraries – lance2k Aug 09 '21 at 10:52
  • As I said, there's no guarantee about which lib is picked up and likely the same libs are always picked up on same machine. – Gaël J Aug 09 '21 at 15:47
  • i have something similar, but cant fix it - https://stackoverflow.com/questions/72535192/java-lang-nosuchmethoderror-boolean-com-google-api-client-http-httptransport-i – amarnath harish Jun 07 '22 at 17:31