The attached script decodes the attached xml file. The xml file is encoded in ISO-8859-1. This triggers the iconv based decoding in rexml/encoding.rb:36
ICONV.rb is implemented as listed below. As far as I can tell this can never work. @encoding is not defined in ICONVEncoder so it will always be nil. In the end this causes the TypeError listed below.
The version of ICONV.rb that is included in JRuby does not match the one from http://www.germane-software.com/software/rexml/. The only reference to the diff between the two I could find is https://gist.github.com/1420725. The change that is applied there is what introduced this error. Before that patch the iconv decoding methods where defined in the REXML::Encoding module which does have the @encoding field.
I've attached a possible fix in the form of a patched version of ICONV.rb.
Iconv.conv(UTF_8, @encoding, str)
Iconv.conv(@encoding, UTF_8, content)
iconv = ICONVEncoder.new
register("ICONV") do |obj|
Iconv.conv(UTF_8, obj.encoding, nil)
obj.encoder = iconv
TypeError that is triggered during decoding
TypeError: can't convert NilClass into String
initialize at org/jruby/RubyIconv.java:207
conv at org/jruby/RubyIconv.java:391
encode at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/encodings/ICONV.rb:12
encoding= at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/source.rb:55
initialize at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/source.rb:45
initialize at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/source.rb:160
create_from at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/source.rb:16
stream= at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/parsers/baseparser.rb:121
initialize at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/parsers/baseparser.rb:110
initialize at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/parsers/treeparser.rb:9
build at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/document.rb:227
initialize at /opt/jruby-1.6.7/lib/ruby/1.8/rexml/document.rb:43