splunk / splunk-sdk-ruby

Splunk Software Development Kit for Ruby
http://dev.splunk.com
Apache License 2.0
36 stars 21 forks source link

Splunk SDK not working with JRUBY 1.7.19 #40

Open moofish32 opened 9 years ago

moofish32 commented 9 years ago

I am receiving Nokogiri errors attempting the basic tutorials with jruby 1.7.19 splunk sdk 1.0.4.

I am receiving the following error message when running the tests and similar error in IRB

Error: test_nokogiri_atom_without_feed(TestAtomFeed) : NoMethodError: undefined method `name' for []:Nokogiri::XML::NodeSet

✗ java -version java version "1.7.0_72" Java(TM) SE Runtime Environment (build 1.7.0_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

However the same scenario is successful with MRI ruby 2.1.5.

shakeelmohamed commented 9 years ago

Hi @moofish32, we will look into this.

shakeelmohamed commented 9 years ago

Hi @moofish32, I'm able to reproduce your error. But, if I run gem install nokogiri --pre that seems to solve the problem by getting a prerelease version. This issue may be directly related to jruby and nokogiri. They have some other resources you may want to look into:

If that doesn't solve your problem, please let us know

itay commented 8 years ago

Closing as there are no updates.

itzikh commented 7 years ago

Hi, I have the exact same issue and the links that were added above did not give a clue about how to fix this. Is there any solution that was found?

My partial runtime error:

:error=>#<NoMethodError: undefined methodname' for []:Nokogiri::XML::NodeSet>, :backtrace=>["C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-``1.0.5/lib/splunk-sdk-ruby/atomfeed.rb:255:inread_entry_field'"

shakeelmohamed commented 7 years ago

@itzikh did you run gem install nokogiri --pre?

itzikh commented 7 years ago

@shakeelmohamed yes, i have. If it's any help, i'm using the sdk as an input plugin for logstash and thats when i get the error. If any logs are needed, ill be happy to provide.

shakeelmohamed commented 7 years ago

@itzikh sure, we can take a look with some additional logs.

itzikh commented 7 years ago

Ok, So these are the mentioned logs - working with Splunk sdk as a logstash input:

11:49:10.196 [LogStash::Runner] FATAL logstash.runner - An unexpected error occurred! {:error=>#<NoMethodError: undefined method `name' for []:Nokogiri::XML::NodeSet>, 
:backtrace=>["C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/atomfeed.rb:255:in `read_entry_field'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/atomfeed.rb:210:in `read_entry'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/nokogiri-1.6.8.1-java/lib/nokogiri/xml/node_set.rb:187:in `each'", "org/jruby/RubyInteger.java:133:in `upto'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/nokogiri-1.6.8.1-java/lib/nokogiri/xml/node_set.rb:186:in `each'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/atomfeed.rb:204:in `read_entry'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/atomfeed.rb:107:in `initialize'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/entity.rb:163:in `refresh'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/entity.rb:43:in `initialize'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/entity/job.rb:49:in `initialize'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/collection/jobs.rb:67:in `create'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/splunk-sdk-ruby-1.0.5/lib/splunk-sdk-ruby/service.rb:176:in `create_search'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/local_gems/3b2de46c/logstash-input-splunk-0.1.0/lib/logstash/inputs/splunk.rb:68:in `run'", "org/jruby/RubyProc.java:281:in `call'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/local_gems/3b2de46c/logstash-input-splunk-0.1.0/lib/logstash/inputs/splunk.rb:104:in `run'"]}
11:49:10.266 [Ruby-0-Thread-19: C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/server.rb:296] DEBUG logstash.agent - 2017-01-11 11:49:10 +0200: Listen loop error: #<Errno::EBADF: Bad file descriptor - Bad file descriptor>
11:49:10.266 [Ruby-0-Thread-16: C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/reactor.rb:136] DEBUG logstash.agent - Error in reactor loop escaped: Bad file descriptor - Bad file descriptor (Errno::EBADF)
11:49:10.333 [Ruby-0-Thread-19: C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/server.rb:296] DEBUG logstash.agent - org/jruby/RubyIO.java:3705:in `select'
C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/server.rb:322:in `handle_servers'
C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/server.rb:296:in `run'
11:49:10.333 [Ruby-0-Thread-16: C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/reactor.rb:136] DEBUG logstash.agent - ["org/jruby/RubyIO.java:3705:in `select'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/reactor.rb:29:in `run_internal'", 
"C:/Users/---/Desktop/logstash-5.0.2/logstash-5.0.2/vendor/bundle/jruby/1.9/gems/puma-2.16.0-java/lib/puma/reactor.rb:138:in `run_in_thread'"]

This only happens when running service.create_search and does not happen with service.create_oneshot

itzikh commented 7 years ago

@shakeelmohamed just a small update, i removed the nokogiri gem completely and re installed it using gem install nokogiri --pre just to be on the safe side. still did not work.

Do you have any idea on weather or not this is going to be fixed?

tdhellmann commented 7 years ago

Hi @itzikh - I suspect there is something going on with that version of nokogiri. Can you try uninstalling nokogiri and running the examples again? The SDK should run without it.

itzikh commented 7 years ago

Hi @tdhellmann , I uninstalled nokogiri (double checked with gem list) but still the exact same error occurs.

tdhellmann commented 7 years ago

Wait, the same exact error? What's the result of running:

ruby -e "require 'nokogiri'"

itzikh commented 7 years ago

I found a workaround to this problem (Meaning, Not using create_search) But for the sake of solving this, This is the error i get after running ruby -e "require 'nokogiri'":

C:\Users\---\---\--->ruby -e "require 'nokogiri'"
C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- nokogiri (LoadError)
        from C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from -e:1:in `<main>'