Another jruby NAMESPACE_ERR #801

Closed
jcoyne opened this Issue Nov 30, 2012 · 4 comments

Projects

None yet

3 participants

@jcoyne
jcoyne commented Nov 30, 2012

Similar to #683, but only occurs when you write a graph:

This program:

  require 'rubygems'
  require 'rdf'
  require 'rdf/rdfxml'

  graph = RDF::Graph.new
  s = RDF::URI.new("http://rubygems.org/gems/rdf")
  p = RDF::DC.creator
  o = RDF::URI.new("http://ar.to/#self")
  graph << RDF::Statement.new(s, p, o)
  RDF::RDFXML::Writer.open("test.rdf") do |writer|
    writer.write_graph(graph)
  end

Produced this file in MRI 1.9.3

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns0="http://purl.org/dc/terms/">
  <rdf:Description rdf:about="http://rubygems.org/gems/rdf">
    <ns0:creator rdf:resource="http://ar.to/#self"/>
  </rdf:Description>
</rdf:RDF>

But when running in jruby 1.7.0 with nokogiri 1.5.5 I get this stack trace:

null:-1:in `renameNode': org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
    from XmlNode.java:451:in `relink_namespace'
    from XmlNode.java:1385:in `adoptAs'
    from XmlNode.java:1486:in `add_child_node'
    from XmlNode$INVOKER$i$1$0$add_child_node.gen:-1:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from FCallOneArgNode.java:36:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from IfNode.java:118:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:182:in `call'
    from DefaultMethod.java:192:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from IfNode.java:116:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:112:in `call'
    from InterpretedMethod.java:126:in `call'
    from DefaultMethod.java:167:in `call'
    from CachingCallSite.java:296:in `cacheAndCall'
    from CachingCallSite.java:72:in `call'
    from FCallManyArgsNode.java:60:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:209:in `evalBlockBody'
    from Interpreted19Block.java:160:in `yield'
    from Block.java:130:in `yield'
    from RubyArray.java:1605:in `eachCommon'
    from RubyArray.java:1612:in `each'
    from RubyArray$INVOKER$i$0$0$each.gen:-1:in `call'
    from CachingCallSite.java:316:in `cacheAndCall'
    from CachingCallSite.java:145:in `callBlock'
    from CachingCallSite.java:154:in `callIter'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:209:in `evalBlockBody'
    from Interpreted19Block.java:160:in `yield'
    from Block.java:130:in `yield'
    from RubyArray.java:1605:in `eachCommon'
    from RubyArray.java:1612:in `each'
    from RubyArray$INVOKER$i$0$0$each.gen:-1:in `call'
    from CachingCallSite.java:316:in `cacheAndCall'
    from CachingCallSite.java:145:in `callBlock'
    from CachingCallSite.java:154:in `callIter'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from IfNode.java:116:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:225:in `call'
    from DefaultMethod.java:208:in `call'
    from CachingCallSite.java:346:in `cacheAndCall'
    from CachingCallSite.java:204:in `call'
    from FCallTwoArgNode.java:38:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:209:in `evalBlockBody'
    from Interpreted19Block.java:160:in `yield'
    from Block.java:130:in `yield'
    from RubyArray.java:1605:in `eachCommon'
    from RubyArray.java:1612:in `each'
    from RubyArray$INVOKER$i$0$0$each.gen:-1:in `call'
    from CachingCallSite.java:316:in `cacheAndCall'
    from CachingCallSite.java:145:in `callBlock'
    from CachingCallSite.java:154:in `callIter'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:139:in `call'
    from DefaultMethod.java:176:in `call'
    from CachingCallSite.java:306:in `cacheAndCall'
    from CachingCallSite.java:136:in `call'
    from VCallNode.java:88:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from IfNode.java:116:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:247:in `call'
    from DefaultMethod.java:216:in `call'
    from SuperCallSite.java:386:in `cacheAndCall'
    from SuperCallSite.java:238:in `callBlock'
    from SuperCallSite.java:243:in `call'
    from SuperCallSite.java:109:in `callVarargs'
    from ZSuperNode.java:104:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:247:in `call'
    from DefaultMethod.java:216:in `call'
    from CachingCallSite.java:356:in `cacheAndCall'
    from CachingCallSite.java:213:in `callBlock'
    from CachingCallSite.java:217:in `call'
    from RubyClass.java:874:in `newInstance'
    from RubyClass$INVOKER$i$newInstance.gen:-1:in `call'
    from CachingCallSite.java:356:in `cacheAndCall'
    from CachingCallSite.java:213:in `callBlock'
    from CachingCallSite.java:217:in `call'
    from CallTwoArgBlockPassNode.java:62:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:209:in `evalBlockBody'
    from Interpreted19Block.java:160:in `yield'
    from Block.java:130:in `yield'
    from RubyIO.java:1180:in `open'
    from RubyIO$INVOKER$s$0$0$open.gen:-1:in `call'
    from DynamicMethod.java:216:in `call'
    from CachingCallSite.java:356:in `cacheAndCall'
    from CachingCallSite.java:213:in `callBlock'
    from CachingCallSite.java:222:in `callIter'
    from CallTwoArgBlockNode.java:62:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:204:in `call'
    from DefaultMethod.java:200:in `call'
    from CachingCallSite.java:336:in `cacheAndCall'
    from CachingCallSite.java:179:in `callBlock'
    from CachingCallSite.java:188:in `callIter'
    from jruby_test.rb:10:in `__file__'
    from jruby_test.rb:-1:in `load'
    from Ruby.java:770:in `runScript'
    from Ruby.java:763:in `runScript'
    from Ruby.java:640:in `runNormally'
    from Ruby.java:489:in `runFromMain'
    from Main.java:375:in `doRunFromMain'
    from Main.java:264:in `internalRun'
    from Main.java:230:in `run'
    from Main.java:214:in `run'
    from Main.java:194:in `main'
@jcoyne
jcoyne commented Dec 11, 2012

Looks great @mbklein +1

@mbklein mbklein added a commit to mbklein/nokogiri that referenced this issue Dec 19, 2012
@mbklein mbklein * Fix the NAMESPACE_ERR issues (e.g, Issue #801)
* Untangle handling of namespaces in JRuby
* Secure XmlNode and NokogiriNamespaceCache against internal node object changes
6acedf5
@jcoyne jcoyne referenced this issue in projecthydra/active_fedora Jan 7, 2013
Open

ActiveFedora should support jruby #24

@sairam
sairam commented Feb 2, 2013

+1

@mbklein mbklein added a commit to mbklein/nokogiri that referenced this issue Feb 12, 2013
@mbklein mbklein * Fix the NAMESPACE_ERR issues (e.g, Issue #801)
* Untangle handling of namespaces in JRuby
* Secure XmlNode and NokogiriNamespaceCache against internal node object changes
931f90d
@flavorjones
Member

Made two comments at https://github.com/sparklemotion/nokogiri/pull/846/files#L4R36 about lack of test coverage. I've also made a subsequent commit to change magic numbers to constants.

If you've got a response on the test coverage, let me know. In the meantime, I'm merging and this will be part of 1.5.7.rc2.

@flavorjones flavorjones added a commit that referenced this issue Mar 11, 2013
@mbklein @flavorjones mbklein + flavorjones * Fix the NAMESPACE_ERR issues (e.g, Issue #801)
* Untangle handling of namespaces in JRuby
* Secure XmlNode and NokogiriNamespaceCache against internal node object changes
2fa14db
@flavorjones
Member

The above pull request should fix in 1.5.7.rc2. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment