Reputation: 169
I'm new using splunk and the java sdk api.
I combined a grails environnement with that api and getting an error on the simplest search, giving into the doc exemple :
Here is my code :
package fr.ftprod.splunk
import com.splunk.Job
import com.splunk.JobCollection
import com.splunk.Service
class LoginController {
def index() {
//connect and login
def connectionParameters = [host: 'localhost', username: 'username' ,password: 'password']
Service service = Service.connect(connectionParameters)
String myQuery = 'source="source" get status=200'
// Retrieves the collection of search jobs
def jobs = service.getJobs()
}
}
Here is my grails stacktrace :
| Error 2013-06-24 14:15:10,689 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver - UnsupportedOperationException occurred when processing request: [GET] /splunk/ Stacktrace follows: Message: null Line | Method ->> 159 | entrySet in com.splunk.ResourceCollection - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 621 | putAll in java.util.HashMap | 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run
in java.util.concurrent.ThreadPoolExecutor$Worker ^ 722 | run . . . in java.lang.Thread
Any idea ?
Thanks
Upvotes: 0
Views: 396
Reputation: 259
I can't tell what's causing the error but what is it that you are trying to do? Because in the code you posted, you are not running any searches or executing any job. I am new to grails but I set up a hello world like example and it appears to be working. Code Sample:
package helloworld
import com.splunk.Service
class HelloController {
def index() {
render "Hello World"
def connectionParameters = [host: 'localhost', username: 'admin' ,password: 'changeme']
def service = Service.connect(connectionParameters)
render "<br>"
render service.getToken()
def jobs = service.getJobs()
render "<br>"
render jobs.size()
}
}
Output:
Hello World
Splunk 1d1f464ac1b4051089ab3388aac60c5d
4
Try to copy/paste the code, run it and tell us what happens and where exactly it chokes.
I tried this with Grails 2.3.3, Splunk 5.0.2, Splunk Java SDK 1.1 and Java 1.6. What versions are you on?
Upvotes: 0