ruby-rdf / rdf-rdfxml

Ruby RDF/XML reader/writer for RDF.rb.
http://rubygems.org/gems/rdf-rdfxml
The Unlicense
17 stars 7 forks source link

Error reading RDFXML using jruby 1.7.3 #24

Closed jcoyne closed 10 years ago

jcoyne commented 11 years ago
require 'rdf'
require 'rdf/rdfxml'
stmt = '<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.w3.org/2000/10/rdf-tests/rdfcore/rdfms-empty-property-elements/Manifest.rdf#test009" xmlns:ns0="http://random.ioctl.org/#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace">
  <rdf:Description rdf:about="http://random.ioctl.org/#bar">
    <ns0:someProperty rdf:parseType="Literal"/>

  </rdf:Description>
</rdf:RDF>'

RDF::RDFXML::Reader.new(stmt).each {|x| puts x}

Causes a jruby stack trace:

Java::JavaLang::NullPointerException: 
    from org.jruby.runtime.callsite.CachingCallSite.pollAndGetClass(CachingCallSite.java:433)
    from org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:140)
    from org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:154)
    from org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:64)
    from org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    from org.jruby.ast.IfNode.interpret(IfNode.java:116)
    from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
    from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139)
    from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:172)
    from org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:56)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
    from org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:64)
    from org.jruby.ast.IfNode.interpret(IfNode.java:118)
... 346 levels...
    from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
    from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
    from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:188)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    from Users.justin.$_dot_rvm.rubies.jruby_minus_1_dot_7_dot_3.bin.irb.__file__(/Users/justin/.rvm/rubies/jruby-1.7.3/bin/irb:13)
    from Users.justin.$_dot_rvm.rubies.jruby_minus_1_dot_7_dot_3.bin.irb.load(/Users/justin/.rvm/rubies/jruby-1.7.3/bin/irb)
    from org.jruby.Ruby.runScript(Ruby.java:815)
    from org.jruby.Ruby.runScript(Ruby.java:808)
    from org.jruby.Ruby.runNormally(Ruby.java:679)
    from org.jruby.Ruby.runFromMain(Ruby.java:528)
    from org.jruby.Main.doRunFromMain(Main.java:390)
    from org.jruby.Main.internalRun(Main.java:279)
    from org.jruby.Main.run(Main.java:221)
    from org.jruby.Main.main(Main.java:201)

I'm willing to work on a patch for this issue, but wanted to log it here.

jcoyne commented 11 years ago

I'm blocked from working on this by this other issue: https://github.com/ruby-rdf/rdf-spec/issues/20

gkellogg commented 11 years ago

RDF/XML has always been problematic on JRuby, because Nokogiri does not work equivalently. This gem is in serious need of a major re-write, but has been a low priority for me. Any help is appreciated.

I'll check it out however, to see if I can quickly see what that particular spec might be triggering.

jcoyne commented 11 years ago

I've been working with some associates to fix the differences in Nokogiri. I've got a big patch in progress for this gem, but I can't finish it because of the changes necessitated by ruby-rdf/rdf-spec#20 .

gkellogg commented 10 years ago

The use of Nokogiri for writing XML was not-strictly compliant and there was really no good way to make it work. The new version of RDFXML::Writer leverages RDFa::Writer and uses Haml templates for generating RDF/XML and passes all the original tests.