1

I've been trying to solve this problem for 3 days now and I simply can't find a solution.

So, I have downloaded the Jruby-complete-1.7.3 jar. After which, I have attempted to install the gem 'nokogiri' using the basic method:

java -jar jruby-complete-1.7.3 -S gem install nokogiri

In addition, I have a separate jar which was created using the Gem-In-A-Jar method. Note that this extra jar is only a result of trying to fix the problem below.

In both cases, when I test it out via the irb, it shows me the following:

require 'nokogiri'
=> true

Now, the problem arises when I try to use the jruby jar in an applet within my web application. To be specific, I'll mention that I can load the jar itself and interact with it from my applet, if I don't try to access any gem files (specifically nokogiri in this case). However, to make this happen, I am required to sign the jar.

If the jar is unsigned, it fails to work, as my Ruby instance fails to be created. When it is signed, it works fine.

The issue is that once the jar is signed, I attempt to call the same command I did before, and I get the following error:

require 'nokogiri'

LoadError: load error: nokogiri/nokogiri -- java.lang.RuntimeException: 
(LoadError) class "nokogiri.EncodingHandler$INVOKDER$s$1$0$get"'s signer
information does not match signer information of other classes in the same
package.

I've been searching around quite a bit in regards to the cause and potential solutions to this error, but I am unable to figure out why the gem itself is causing it. While using the Gem-In-A-Jar method, I did use the same key to sign the gem_jar.

UPDATE: Turns out I was wrong. Each gem installed comes with its own jar file within the lib directory. These jars need to be signed with the same key. After doing so, the above issue was resolved. However, the one below remains.

Additionally, when I attempt to run it in my web-application, I get the following message:

classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems.rb:396 warning: 
can't canonicalize loaded names due to security restrictions; disabling

I assume this is the exception thrown when the error mentioned above occurs, but I can't say for sure.

I would sincerely appreciate anyone that can tell me what I've done wrong, or provide suggestions on how to fix it. If I have phrased the question wrong or have not provided enough information, do let me know.

Thanks

  • I suspect one solution is to use the SDK tools to strip the signatures from every Jar and digitally sign them all freshly. Do you have classes from the same package in different Jars? – Andrew Thompson Apr 16 '13 at 03:51
  • Thanks for the reply! I suspect you might be right, I shall give it a go and see. And no, the classes should only be within the single jruby-complete-1.7.3 jar. – Daniel Deak Apr 16 '13 at 10:05
  • I've edited the post. I was in fact wrong, the nokogiri gem comes with a jar file that needed to be signed with the same key as well. Thanks again for the reply, really helped me get that sorted after all these days. However, it still doesn't work in my applet. I still get the "can't canonicalize" error. – Daniel Deak Apr 16 '13 at 11:05
  • Questions on SO really should focus on one issue. 'How to make my app. work?' is generally more than one issue. I suggest you accept my answer on this one (coming shortly) and ask a new question about the ..thing I'd not heard mentioned until that comment. – Andrew Thompson Apr 16 '13 at 11:16
  • Yeah that's fair. Originally I did think they were directly related to each other, but turns out they are separate problems. Thanks again! – Daniel Deak Apr 16 '13 at 12:40

1 Answers1

0

One solution is to use the SDK tools to strip the signatures from every Jar and digitally sign them all freshly.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433