Unable to get data from Gmail API

I use this tutorial to connect to Gmail API: Java Quickstart  |  Gmail API  |  Google Developers I would like to make a keyword in Katalon Studio, which depends on Gmail API. I modified from sample code that line:

InputStream in = GmailQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);

to this:

InputStream ins = new FileInputStream(CREDENTIALS_FILE_PATH);

I have added also following line:
import com.google.api.client.http.HttpRequest;
JAR files are imported, project is running and browser window is opened to get token. After successful authorization I got error message:

Caused by: java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequest.setResponseReturnRawInputStream(Z)Lcom/google/api/client/http/HttpRequest;

List of imported dependencies:


I tried the quickstart tutorial outside Katalon Studio (Emacs + Gradle + JDK11). It worked fine without any change.


I assume that

  • you are using Katalon Studio 7.9.1
  • you downloaded the aforementioned jar files and located in the <projectdir>/Drivers folder

You mentioned that you chose the following jar.

On the other hand in any Katalon Studio project of v7.9.1 has <projecitdir>/.classpath file. In the .classpath file I found a line:

	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/com.google.http-client.google-http-client_1.22.0.jar"/>

This means that com.google.http-client.google-http-client_1.22.0.jar file is bundled in Katalon Studio. The bundled jar will have precedence over the jar files in the <projectdir>/Drivers folder. To be precise, the precedence is determined by the order of <classpathentriy> lines in the .classpath file. Earlier wins.

Caused by: java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequest.setResponseReturnRawInputStream(Z)Lcom/google/api/client/http/HttpRequest;

I suppose that this Exception occured becase the com.google.api.client.http.HttpRequest class was loaded from the older version 1.22.0.

How to workaround?

The .classpath file is given by Katalon to you. You can not change it at all. You are suppose to live with the versions of external libs bundled in the Katalon Studion ver x.x.x if you are to develop a Custom Keyword for Katalon Studio.

In orther words, you can not take initiative which version of google-api-client-x.x.x.jar to choose. Rather, you have to find out which version of google-api-client-x.x.x.jar can coexist with the com.google.http-client.google-http-client_1.22.0.jar which is bundled in KS, and use that version to build your Custom Keyword.

1 Like

Older version Gmail API jar might not work well with the recent version of Gmail services. I am not sure, but the google-api-client-1.23.0 has already been updated to 1.31.3 until now. I suppose there have been many changes in the Gmail service. Therefore I guess @plaidshirtakos may find that he really need the recent version of google-api-client-x.x.x.jar such as 1.31.3. In this case he will get stuck, as he can not take the initiative to choose the versions of Google API.


The Gmail API used by the “Read and Write Gmail Messages plugin” might be too old to work with the recent version of Gmail service. This might be the reason why many people report problems about the plugin. For example,

1 Like


Why this jar is bundled in Katalon Studio 7.9.1?
For what use case is it used?
Is it really necessary to be bundled?

Thanks @kazurayam ! HttpRequest.setResponseReturnRawInputStream was introduced in google-http-client 1.29.0, so I need at least that version for that keyword.


Is there any way for @plaidshirtakos to change the build path of KS so that his custom Groovy code refer to the google-http-client-1.39.1.jar in the Drivers folder rather than the com.google.http-client.google-http-client_1.22.0.jar bundled in the KS 7.9.1?

I am not sure if it would help, but Katalon Studio offers a way to exclude built-in libraries from the build path.


Thank you for your reply. I believe that the Excluding built-in jars would solve his problem.


I suppose you would want to check from which jar file the com.google.api.client.http.HttpRequest is loaded. You can use the following Test Case script.

import com.google.api.client.http.HttpRequest

URL u = HttpRequest.class.getResource("/" + HttpRequest.class.getName().replaceAll("\\.", "/") + ".class");

When I ran this, I got the following output:

14:51:35.222 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2021-03-31 14:51:35.225 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TCi
2021-03-31 14:51:36.365 DEBUG testcase.TCi                             - 1: u = HttpRequest.getResource("/" + getName().replaceAll("\.", "/") + ".class")
2021-03-31 14:51:36.394 DEBUG testcase.TCi                             - 2: out.println(u)


2021-03-31 14:51:36.447 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TCi
1 Like

I use free edition of KS, so I can’t use the excluding option, because it is deactivated.

Thanks, I checked it, /Katalon_Studio_Windows_64-7.9.0/plugins/com.google.http-client.google-http-client_1.22.0.jar is in use, so yes, NoSuchMethodError is caused by this.

The last resort for you would be removing the /Katalon_Studio_Windows_64-7.9.0/plugins/com.google.http-client.google-http-client_1.22.0.jar file. You want to remove it manually by rm file in command line or DEL in Windows Explorer. Just try to see what sort of difficulties you get next.

I have tried to remove it and to change it too. There is same error message in log, when I try to execute KS.

org.osgi.framework.BundleException: Could not resolve module: com.kms.katalon.activation [26]
Unresolved requirement: Require-Bundle: com.kms.katalon.application
-> Bundle-SymbolicName: com.kms.katalon.application; bundle-version=“”; singleton:=“true”
com.kms.katalon.application [28]
Unresolved requirement: Require-Bundle: com.google.http-client.google-http-client
Unresolved requirement: Require-Bundle: com.kms.katalon.controller
-> Bundle-SymbolicName: com.kms.katalon.controller; bundle-version=“”; singleton:=“true”
com.kms.katalon.controller [72]
Unresolved requirement: Require-Bundle: com.kms.katalon.core.webservice
-> Bundle-SymbolicName: com.kms.katalon.core.webservice; bundle-version=“”; singleton:=“true”
com.kms.katalon.core.webservice [78]
Unresolved requirement: Require-Bundle: com.google.http-client.google-http-client

It seems that Katalon Studio really requires the /Katalon_Studio_Windows_64-7.9.0/plugins/com.google.http-client.google-http-client_1.22.0.jar file. Now we know we can not remove the jar.

So, @plaidshirtakos, you are stuck. It seems that you can not work on the Gmail API in Katalon Studio unless Katalon Team works on upgrading the Gmail API-related bundled dependencies.

1 Like

@ThanhTo , @duyluong : Are you planning to update it in the near future?

Hi @plaidshirtakos,

To prevent adding com.google.http-client.google-http-client_1.22.0.jar to project classpath, you should go to Project Settings/Library Management and add this jar name to Exclude field then reopen your project.

References: https://docs.katalon.com/katalon-studio/docs/external-libraries.html#exclude-built-in-libraries

1 Like


Why this jar is bundled in Katalon Studio 7.9.1?
For what use case is it used?
Is it really necessary to be bundled?

This jar is a dependency of Katalon Studio Web Service engine, we will consider upgrading this library if it doesn’t affect too much with our Web Service engine.

1 Like

I have the same error too :sob::sob::sob:

i remove this lib from library management and i found this error now :

java.lang.NoClassDefFoundError: **LJsonFactory**;
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.getCustomKeywordClassAndSetMetaClass(CustomKeywordDelegatingMetaClass.java:107)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at LireGoogleSheet.run(LireGoogleSheet:26)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1672914633679.run(TempTestCase1672914633679.groovy:25)
Caused by: java.lang.ClassNotFoundException: JsonFactory
	... 14 more

@plaidshirtakos : Did find a solution ?

It’s Works thank u.