Search code examples
rubyxsltnokogirijruby

How should I debug a Nokogiri Null Pointer exception?


A contractor created a fairly complex XSLT for a client of mine. It works great in various transform testing tools, using real data from our application. But Nokogiri barfs on it during transform. With $VERBOSE and $DEBUG set, I still get the uninformative:

Exception `RuntimeError' at nokogiri/XsltStylesheet.java:231 - java.lang.NullPointerException

So I thought I would create a custom Nokogiri Gem with some debug code in it, using this in my Gemfile:

gem 'nokogiri', :git => 'ssh://git@192.168.185.65:7999/bssc/nokogiri.git'

That doesn't work because of a versioning issue I don't understand how to resolve:

Source does not contain any versions of 'nokogiri java'

So at this point I thought I'd reach out and ask the community for a better idea. I'm sure it's something in the stylesheet that Nokogiri is not happy with, but it is difficult to locate because of the complexity of the XSLT.

Suggestions?


Solution

  • ... have done some Java native ext lifting with Nokogiri (performance/cleanup updates in 1.7/1.8)

    it depends whether you have a trace that points to a reasonable location or not, try jruby -Xbacktrace.style=raw ... if that does not reveal valuable insight you might need to get into building the gem yourself (there's a rake task for it just make sure you're doing it under JRuby).

    you can not use Bundler with :git since the .gemspec is generated depending on the Ruby platform, thus you will need to build and manually gem install (adjust the version and set it with Bundler so you know which one you're using).

    good luck!