jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-4115

cipher.rb:24: superclass must be a Class (Module given) (TypeError)

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: JRuby-OpenSSL 0.5
  • Fix Version/s: JRuby 1.7.0.pre1
  • Component/s: OpenSSL
  • Labels:
    None
  • Environment:
    Java 1.6 on CentOS

Description

I am using JRuby v1.3.1 with JRuby-OpenSSL v0.5.2 (gem added to a jruby-complete.jar). When I need to use OpenSSL to consume a SOAP Web Service I get an error. Looking at the code it appears that indeed a module is being subclassed.

The error details are here:

http://gist.github.com/213842

This may be a fix?:

klass = Class.new {
 include Cipher
 define_method(:initialize) do |*args|
   cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
   super(cipher_name)
 end
}
const_set(name, klass)

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Jason Goecke added a comment - 20/Oct/09 8:01 AM

I did give the above patch a try, but then this error pops up:

cipher.rb:25: wrong argument type Class (expected Module) (TypeError)

Show
Jason Goecke added a comment - 20/Oct/09 8:01 AM I did give the above patch a try, but then this error pops up: cipher.rb:25: wrong argument type Class (expected Module) (TypeError)
Hide
Permalink
Jason Goecke added a comment - 23/Oct/09 3:15 PM

Another couple of data points. First, the far end had an SSL config issue on Tomcat that was this one:

http://marc.info/?l=openssl-users&m=121136394005343&w=2

Once fixed, I could then connect to the SSL with jruby-openssl 0.5.2 no problem. But, when trying to do so from within a Jar with jruby-complete having the gem embedded, I still get this error.

Show
Jason Goecke added a comment - 23/Oct/09 3:15 PM Another couple of data points. First, the far end had an SSL config issue on Tomcat that was this one: http://marc.info/?l=openssl-users&m=121136394005343&w=2 Once fixed, I could then connect to the SSL with jruby-openssl 0.5.2 no problem. But, when trying to do so from within a Jar with jruby-complete having the gem embedded, I still get this error.
Hide
Permalink
Charles Oliver Nutter added a comment - 27/Oct/09 11:02 AM

The code in question seems to be just broken. It's trying to Class.new(Cipher), intending to pick up the Cipher class later in that same file. But of course the constant is not defined by the time we reach Class.new unless the rest of openssl has booted. I can produce the error easily:

~/projects/jruby ➔ jruby -rubygems -e "require 'openssl/cipher'"
/Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24:in `initialize': superclass must be a Class (Module given) (TypeError)
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24:in `new'
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:23:in `each'
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:23
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:36:in `require'
	from /Users/headius/projects/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'

Could some library perhaps be requiring openssl/cipher directly? Moving the subsequent definition (or really, reopening) of the Cipher class above the Class.new code should fix this particular issue, but if it's not loading the rest of openssl it's unlikely to function even then. Adding a require 'jopenssl.jar' to the top of the cipher.rb file also should fix it, but it seems a little cumbersome. Thoughts?

Show
Charles Oliver Nutter added a comment - 27/Oct/09 11:02 AM The code in question seems to be just broken. It's trying to Class.new(Cipher), intending to pick up the Cipher class later in that same file. But of course the constant is not defined by the time we reach Class.new unless the rest of openssl has booted. I can produce the error easily:
~/projects/jruby ➔ jruby -rubygems -e "require 'openssl/cipher'"
/Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24:in `initialize': superclass must be a Class (Module given) (TypeError)
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24:in `new'
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:24
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:23:in `each'
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:23
	from /Users/headius/projects/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:36:in `require'
	from /Users/headius/projects/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
Could some library perhaps be requiring openssl/cipher directly? Moving the subsequent definition (or really, reopening) of the Cipher class above the Class.new code should fix this particular issue, but if it's not loading the rest of openssl it's unlikely to function even then. Adding a require 'jopenssl.jar' to the top of the cipher.rb file also should fix it, but it seems a little cumbersome. Thoughts?
Hide
Permalink
Charles Oliver Nutter added a comment - 27/Oct/09 11:09 AM

After looking I noticed that several files had commented out require 'openssl', which probably was the source of this. I fixed that in 5eeee02 and tested a newly-built gem and it appears to work fine. Perhaps you could pull from github and try to build one to confirm it?

Show
Charles Oliver Nutter added a comment - 27/Oct/09 11:09 AM After looking I noticed that several files had commented out require 'openssl', which probably was the source of this. I fixed that in 5eeee02 and tested a newly-built gem and it appears to work fine. Perhaps you could pull from github and try to build one to confirm it?
Hide
Permalink
Jason Goecke added a comment - 27/Oct/09 2:20 PM

I gave it a shot but now get this:

===
Exception in thread "main" file:/Users/jsgoecke/Dropbox/Development/billwise_bridge/package/jar/lib/java/jruby-complete.jar!/gems/jruby-openssl-0.5.0.4/lib/openssl/cipher.rb:28:in `const_missing': uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER (NameError)
===

I had bundled the JRuby-Openssl gem into my JRuby-Complete jar. Now, when I did do a gem build on the gemspec from the Github repo, it did report an old version number: 0.5.0.4

Show
Jason Goecke added a comment - 27/Oct/09 2:20 PM I gave it a shot but now get this: === Exception in thread "main" file:/Users/jsgoecke/Dropbox/Development/billwise_bridge/package/jar/lib/java/jruby-complete.jar!/gems/jruby-openssl-0.5.0.4/lib/openssl/cipher.rb:28:in `const_missing': uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER (NameError) === I had bundled the JRuby-Openssl gem into my JRuby-Complete jar. Now, when I did do a gem build on the gemspec from the Github repo, it did report an old version number: 0.5.0.4
Hide
Permalink
Charles Oliver Nutter added a comment - 28/Oct/09 1:59 PM

Sorry about that; the gemspec was part of an old setup to build on Github, which of course doesn't work anymore. I removed them.

To build the gem, gem install hoe and then run "rake gem" within the jruby-openssl dir. Let me know if it's still failing with that gem.

Show
Charles Oliver Nutter added a comment - 28/Oct/09 1:59 PM Sorry about that; the gemspec was part of an old setup to build on Github, which of course doesn't work anymore. I removed them. To build the gem, gem install hoe and then run "rake gem" within the jruby-openssl dir. Let me know if it's still failing with that gem.
Hide
Permalink
Jason Goecke added a comment - 29/Oct/09 9:47 AM

Thank you, that got the build working. Actually used jrake, as rake failed.

I still get the same error:

Exception in thread "main" file:/Users/jsgoecke/Dropbox/Development/billwise_bridge/package/jar/lib/java/jruby-complete.jar!/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:28:in `const_missing': uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER (NameError)

Going to play around a bit more as well.

Show
Jason Goecke added a comment - 29/Oct/09 9:47 AM Thank you, that got the build working. Actually used jrake, as rake failed. I still get the same error: Exception in thread "main" file:/Users/jsgoecke/Dropbox/Development/billwise_bridge/package/jar/lib/java/jruby-complete.jar!/gems/jruby-openssl-0.5.2/lib/openssl/cipher.rb:28:in `const_missing': uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER (NameError) Going to play around a bit more as well.
Hide
Permalink
Charles Oliver Nutter added a comment - 29/Oct/09 3:33 PM

Jason: Post the full backtrace with the updated jruby-openssl and we'll investgate together.

Show
Charles Oliver Nutter added a comment - 29/Oct/09 3:33 PM Jason: Post the full backtrace with the updated jruby-openssl and we'll investgate together.
Hide
Permalink
Jason Goecke added a comment - 02/Nov/09 7:27 PM

Here is the full BT: http://gist.github.com/224690

Show
Jason Goecke added a comment - 02/Nov/09 7:27 PM Here is the full BT: http://gist.github.com/224690
Hide
Permalink
Hiroshi Nakamura added a comment - 23/Apr/10 12:38 AM

The same report based on 0.6.1. http://twitter.com/cyross/status/12628621727

Show
Hiroshi Nakamura added a comment - 23/Apr/10 12:38 AM The same report based on 0.6.1. http://twitter.com/cyross/status/12628621727
Hide
Permalink
Hiroshi Nakamura added a comment - 25/Apr/10 10:10 AM

This error occurs on JRuby 1.4 + jruby-complete.jar. JRuby 1.4 + non-complete.jar is safe. JRuby 1.5 is safe. Still investigating.

Show
Hiroshi Nakamura added a comment - 25/Apr/10 10:10 AM This error occurs on JRuby 1.4 + jruby-complete.jar. JRuby 1.4 + non-complete.jar is safe. JRuby 1.5 is safe. Still investigating.
Hide
Permalink
Nicholas Padilla added a comment - 22/Mar/12 1:11 PM

Hello All,

I am attempting to use jruby-openssl gem inside a project that is packaged inside the jruby-complete.jar. Everything else works - except the jruby-openssl. It is installed inside a gems directory on root, along with the specifications directory. I have attempted several other possible fixes, as explained here : http://www.ruby-forum.com/topic/3889596#1052333 I have gotten two errors, one is a stackoverflow error - which has something to do with the jopenssl java code. I edited the layout and now get this:

NameError: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER

When trying to use NET::SMTP. I am hoping there is a work around for this problem, as I need to have this up and running asap. I am using the latest JRuby - 1.6.7 and this is happening. All you have to do is create a 'hello world' app and package it inside of the JRuby-Complete.jar - then 'require 'smtp''. This will attempt to load OpenSSL but will fail to do so. I have read all kinds of possible culprits for this problem but no real fix. Do I just need to move away from using SMTP in JRuby and just use straight Java? Seems like the only solution to me at this point, I'd rather not have to go that route. Is there a good reason for JRuby not including a working OpenSSL implementation?

Show
Nicholas Padilla added a comment - 22/Mar/12 1:11 PM Hello All, I am attempting to use jruby-openssl gem inside a project that is packaged inside the jruby-complete.jar. Everything else works - except the jruby-openssl. It is installed inside a gems directory on root, along with the specifications directory. I have attempted several other possible fixes, as explained here : http://www.ruby-forum.com/topic/3889596#1052333 I have gotten two errors, one is a stackoverflow error - which has something to do with the jopenssl java code. I edited the layout and now get this: NameError: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER When trying to use NET::SMTP. I am hoping there is a work around for this problem, as I need to have this up and running asap. I am using the latest JRuby - 1.6.7 and this is happening. All you have to do is create a 'hello world' app and package it inside of the JRuby-Complete.jar - then 'require 'smtp''. This will attempt to load OpenSSL but will fail to do so. I have read all kinds of possible culprits for this problem but no real fix. Do I just need to move away from using SMTP in JRuby and just use straight Java? Seems like the only solution to me at this point, I'd rather not have to go that route. Is there a good reason for JRuby not including a working OpenSSL implementation?
Hide
Permalink
Nicholas Padilla added a comment - 22/Mar/12 4:40 PM

Hello Again!

I have solved my problem here, this was the solution. In the jruby-complete.jar you will add to the gem/ dir the jruby-openssl gem. Then take the jruby-openssl/lib/share to the root of the jruby-complete.jar - minus the openssl.jar. This ensures jruby can find all files and initialize the fields as needed.

Show
Nicholas Padilla added a comment - 22/Mar/12 4:40 PM Hello Again! I have solved my problem here, this was the solution. In the jruby-complete.jar you will add to the gem/ dir the jruby-openssl gem. Then take the jruby-openssl/lib/share to the root of the jruby-complete.jar - minus the openssl.jar. This ensures jruby can find all files and initialize the fields as needed.
Hide
Permalink
Hiroshi Nakamura added a comment - 30/Apr/12 12:31 AM

Thanks for providing a workaround! We're now planning to merge JRuby-OSSL to JRuby so this kind of problem would not happen again after that. Users encouraged to use the workaround.

Show
Hiroshi Nakamura added a comment - 30/Apr/12 12:31 AM Thanks for providing a workaround! We're now planning to merge JRuby-OSSL to JRuby so this kind of problem would not happen again after that. Users encouraged to use the workaround.

People

  • Assignee:
    Hiroshi Nakamura
    Reporter:
    Jason Goecke
Vote (0)
Watch (0)

Dates

  • Created:
    19/Oct/09 6:49 PM
    Updated:
    30/Apr/12 12:31 AM
    Resolved:
    30/Apr/12 12:31 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.