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
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...