Tuesday, January 14, 2014

[JRUBY] NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang

I have gone through the work around for this issue successfully , but still not sure if it is a bug of net/ssh gem

Error Details :

NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang
   const_missing at org/jruby/RubyModule.java:2642


The above error encountered when my program tried to open a new channel session. It looks for JavaLang. I just simple add a module of JavaLang which use the package of java.lang and issue resolved. i.e.


require 'java'
require 'rubygems'
require 'net/ssh'


module JavaLang
  include_package "java.lang"
end

class Testing1
   
  def testConnection()
    Net::SSH.start("myhost","user_id", :password => "password" ) do |ssh|
       puts("Connection Established")
      ssh.open_channel do |channel|
        puts("SSH Channel opened successfully")
      end
    end
  end

end



-Khirod

No comments:

Post a Comment