com.google.api.client.googleapis.GoogleUtils.getCertificateTrustStore(), no such method.

154 views
Skip to first unread message

kerne...@gmail.com

unread,
Mar 18, 2015, 9:52:08 AM3/18/15
to google-ca...@googlegroups.com
am working on a Spring-MVC application in which I would like to integrate Google calendar functionality. The problem I am facing currently is the initial httpTransport line is throwing me method not found error. I will paste the code I am trying to execute. Kindly let me know if that is correct.
  • I also wanted to ask where should I give the username as parameter. I guess I will show the code and error.

Error code :

java.lang.NoSuchMethodError: com.google.api.client.googleapis.GoogleUtils.getCertificateTrustStore()Ljava/security/KeyStore;
	com.google.api.client.googleapis.javanet.GoogleNetHttpTransport.newTrustedTransport(GoogleNetHttpTransport.java:55)
	com.journaldev.spring.utility.OAuth.authorizeAndTest(OAuth.java:50)
	com.journaldev.spring.controller.PersonController.listCanvas(PersonController.java:585)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:483)

Code :


private static final String APPLICATION_NAME = "ToolTank";

// Below is where my key.json file is also saved.
private static final java.io.File DATA_STORE_DIR =
new java.io.File(System.getProperty("user.home"), "" +
"/Store/calendar_sample");

private static FileDataStoreFactory dataStoreFactory;

private static HttpTransport httpTransport;

private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();

private static com.google.api.services.calendar.Calendar client;

static final java.util.List<Calendar> addedCalendarsUsingBatch = Lists.newArrayList();

public void authorizeAndTest(){

try {
// Below line gives me an error.
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
Credential credential = authorize();

client = new com.google.api.services.calendar.Calendar.Builder(httpTransport,JSON_FACTORY,credential).setApplicationName(APPLICATION_NAME).build();

showCalenders();
addCalendarsUsingBatch();
Calendar calendar = addCalendar();
updateCalendar(calendar);
addEvent(calendar);
showEvents(calendar);
deleteCalendarInBatch();
deleteCalendar(calendar);
} catch (Exception e) {
e.printStackTrace();
}
}

private static Credential authorize() throws Exception{
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY,
new InputStreamReader(OAuth.class.getResourceAsStream("/Store/calendar_sample/ToolTank-c0cc3b4b7502.json")));
if (clientSecrets.getDetails().getClientId().startsWith("Enter")
|| clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) {
System.out.println(
"Enter Client ID and Secret from https://code.google.com/apis/console/?api=calendar "
+ "into calendar-cmdline-sample/src/main/resources/client_secrets.json");
return null;
}

GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport,JSON_FACTORY,clientSecrets,
Collections.singleton(CalendarScopes.CALENDAR)).setDataStoreFactory(dataStoreFactory).build();

// I would like to access the calendar for the us...@gmail.com mentioned below, is that way correct?
return new AuthorizationCodeInstalledApp(flow,new LocalServerReceiver()).authorize("us...@gmail.com");
}

POM.xml :
<!-- Google calender dependencies -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-calendar</artifactId>
<version>v3-rev119-1.19.1</version>
</dependency>

<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
<version>1.47.1</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-calendar</artifactId>
<version>v3-rev118-1.18.0-rc</version>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.15.0-rc</version>
</dependency>

<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-java6</artifactId>
<version>1.19.0</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-calendar</artifactId>
<version>v3-rev119-1.19.1</version>
</dependency>


<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.18.0-rc</version>
</dependency>

<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.4.1-beta</version>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.19.0</version>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.19.0</version>
</dependency>

<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client-json</artifactId>
<version>1.2.3-alpha</version>
</dependency>


What am I doing wrong guys. Any help would be nice. Thanks a lot.

Reply all
Reply to author
Forward
0 new messages