Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to take ownership of node #841

Closed
dentarg opened this issue Jan 28, 2013 · 6 comments
Closed

Failed to take ownership of node #841

dentarg opened this issue Jan 28, 2013 · 6 comments

Comments

@dentarg
Copy link

dentarg commented Jan 28, 2013

This code:

$ cat modify_dom.rb
dom = Marshal.load(open('dom'))
doc = Nokogiri::XML::Document.wrap(dom)
datasets = doc.xpath('//xfa:datasets', 'xfa' => 'http://www.xfa.org/schema/xfa-data/1.0/')
data = Nokogiri::XML("<form1><text_field01>foo</text_field01></form1>")
datasets.children.first.add_child(data.root)

(here is the code that creates dom)

produces this error:

$ bundle exec ruby modify_dom.rb            
RuntimeError: org.jruby.exceptions.RaiseException: (RuntimeError) Failed to take ownership of node
  add_child_node at nokogiri/XmlNode.java:1538
       add_child at /Users/dentarg/.gem/jruby/1.9.3/gems/nokogiri-1.5.6-java/lib/nokogiri/xml/node.rb:275
          (root) at modify_dom.rb:13

But if I use (found in issue #781)

doc = Nokogiri::XML(Nokogiri::XML::Document.wrap(dom).to_xml)

there's no error.

Seems like there is a bug in Nokogiri, or am I doing something wrong?

I'm using nokogiri (1.5.6-java) and JRuby 1.7.2 on OS X.

@flavorjones
Copy link
Member

@yokolet - any idea what's going on here? Perhaps the document parsed from org.w3c.dom.Document format might not be the same as the one parsed from the equivalent XML?

@flavorjones
Copy link
Member

I'm very sorry, without the original dom file I can't reproduce this issue. Can you help me reproduce what's going on here?

@dentarg
Copy link
Author

dentarg commented Feb 17, 2016

I linked a gist that can create file "dom"... Did you miss that or is it not enough?

On 17 feb. 2016, at 06:41, Mike Dalessio notifications@github.com wrote:

I'm very sorry, without the original dom file I can't reproduce this issue. Can you help me reproduce what's going on here?


Reply to this email directly or view it on GitHub.

@flavorjones
Copy link
Member

The gist requires PDF-related java files that I don't have on my system,
which is why I'm asking.

On Wed, Feb 17, 2016 at 3:02 AM, Patrik Ragnarsson <notifications@github.com

wrote:

I linked a gist that can create file "dom"... Did you miss that or is it
not enough?

On 17 feb. 2016, at 06:41, Mike Dalessio notifications@github.com
wrote:

I'm very sorry, without the original dom file I can't reproduce this
issue. Can you help me reproduce what's going on here?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#841 (comment)
.

@dentarg
Copy link
Author

dentarg commented Feb 20, 2016

@flavorjones all the files needed to create dom, is in the gist, but I have now generated a dom and attached it to the gist, https://gist.github.com/dentarg/4655667/raw/969cc7daaf0a275805e18af74e5a0952b47c3226/dom.

I created it with these versions:

$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

$ ruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server
VM 25.74-b02 on 1.8.0_74-b02 +jit [darwin-x86_64]

I don't think I still have the "original dom file" (but using the exact versions stated in the original post, one should be able to create the same file I guess)

I also added the modify_dom.rb script to the gist and tried it with the new versions, the error is no longer the same:

$ bundle exec ruby modify_dom.rb
RuntimeError: java.lang.NullPointerException
                     add_child_node at nokogiri/XmlNode.java:1677
  add_child_node_and_reparent_attrs at /Users/dentarg/.gem/jruby/2.2.3/gems/nokogiri-1.6.7.2-java/lib/nokogiri/xml/node.rb:830
                          add_child at /Users/dentarg/.gem/jruby/2.2.3/gems/nokogiri-1.6.7.2-java/lib/nokogiri/xml/node.rb:141
                              <top> at modify_dom.rb:7

I guess one should also test all this with a newer iText version, but as it was some years ago I created this issue, I'm no longer working on the project where I discovered this, so I don't have incentive to do so.

@flavorjones
Copy link
Member

I believe this is a dup of #1060 that was fixed by 2fd4158 in v1.10.2.

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

No branches or pull requests

2 participants