All Apps and Add-ons

ResultsReaderJson gives error The import com.google cannot be resolved and JsonReader cannot be resolved to a type

rpatkar
Engager

Hi,

We are using Selenium+Java for our automation and we have integrated splunk sdk using maven dependencies.
we are able to get the Json response by connecting and running the job when we try to display results with the results reader it throws following error:

java.lang.Error: Unresolved compilation problems:
The import com.google cannot be resolved
The import com.google cannot be resolved
JsonReader cannot be resolved to a type
JsonToken cannot be resolved to a variable

Splunk Version : used splunk 1.5 and 1.6 -- getting same error.

<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.6.2.0</version>

Code :
JobResultsArgs resultsArgs = new JobResultsArgs();
resultsArgs.setOutputMode(JobResultsArgs.OutputMode.JSON);
InputStream results = automationLeadJob.getResults(resultsArgs);
ResultsReaderJson resultsReader = new ResultsReaderJson(results);

Thanks

Tags (1)

atpsplunk11
Explorer

Use splunk SDK 1.6.5.0 with gson 2.8.2. This set up works for me fine.

0 Karma

f2mahmud
Engager

Use splunk 1.6,3.0 with gson 2.8. I have been struggling with the same issue and that combination fixed it.

0 Karma

tulinski
Explorer

For me the following dependencies work fine:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.0</version>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>com.splunk</groupId>
    <artifactId>splunk</artifactId>
    <version>1.5.0.0</version>
</dependency>

However I couldn't find gson version working with splunk 1.6.x
When I downloaded splunk sdk 1.6.2 and built it locally I could run my code using ResultsReaderJson when I added ./dist/splunk-1.6.2.jar and ./dist/gson-2.2.4.jar to my classpath (IntelliJ). Then I tried to set splunk and gson versions to 1.6.2.0 and 2.2.4 respectively (in my pom.xml), but I got again the exception:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The import com.google cannot be resolved
    The import com.google cannot be resolved
    JsonReader cannot be resolved to a type
    JsonReader cannot be resolved to a type

shahid285
Path Finder

Hi,
even I am facing the same problem just as @rpatkar, and i followed your advice, but still there is no change in the error. Can you help here please?

Thanks
Mohammed Shahid Nawaz

0 Karma

teresap
Engager

Thank you, downgrading to 1.5.0.0 unblocked me.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...