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!

Database Performance Sidebar Panel Now on APM Database Query Performance & Service ...

We’ve streamlined the troubleshooting experience for database-related service issues by adding a database ...

IM Landing Page Filter - Now Available

We’ve added the capability for you to filter across the summary details on the main Infrastructure Monitoring ...

Dynamic Links from Alerts to IM Navigators - New in Observability Cloud

Splunk continues to improve the troubleshooting experience in Observability Cloud with this latest enhancement ...