Forum: JRuby (NameError) uninitialized constant

0fd9c7f99b996ea1550f5a78dc35254c?d=identicon&s=25 Sumit Parkhani (sumitparkhani)
on 2013-12-26 13:00
Hi,

I am a newbie to JRuby I have issue related to (NameError) uninitialized
constant. it happens when i try to access a ruby class which is at level
module1::module2::class

If i initiate with .new i.e like this module1::module2::class.new i get
error staging as follows
Caused by: org.jruby.exceptions.RaiseException: (NameError)
uninitialized constant module1::module2
 at org.jruby.RubyModule.const_missing(org/jruby/RubyModule.java:2686)

Want to know why this error is coming
8db112f19ce0a69c7e490bbf27256346?d=identicon&s=25 Tobias Pfeiffer (Guest)
on 2013-12-26 13:09
(Received via mailing list)
Attachment: signature.asc (554 Bytes)
Hi there,

this is difficult to say from here. We need sample code to see why it
fails.  This is just guess work/a general explanation now:

At first note that modules and classes in ruby have to start with
capital letters.

and for your definition to work you gotta do:

Module1
  Module2
    MyClass
    end
  end
end

Module1::Module2::MyClass.new

Cheers,
Tobi
2d1b64aaf61046ad166db3009fa8c7dc?d=identicon&s=25 Charles Monteiro (Guest)
on 2013-12-26 13:10
(Received via mailing list)
at first glance that just sounds like you have not required the file in
question i.e. require or require_relative but you dont provide enough
context

Charles
0fd9c7f99b996ea1550f5a78dc35254c?d=identicon&s=25 Sumit Parkhani (sumitparkhani)
on 2013-12-26 13:25
Tobias Pfeiffer wrote in post #1131618:
> Hi there,
>
> this is difficult to say from here. We need sample code to see why it
> fails.  This is just guess work/a general explanation now:
>
> At first note that modules and classes in ruby have to start with
> capital letters.
>
> and for your definition to work you gotta do:
>
> Module1
>   Module2
>     MyClass
>     end
>   end
> end
>
> Module1::Module2::MyClass.new
>
> Cheers,
> Tobi

Hi,
thanks for the quick response ya the name of modules and classes start
with capital letters.

here's the scenario
First part is i have a class which is locate at
Module1
   Module2
     Module3
       MyClass
     end
 def method_test
end
   end
  end
 end

I am calling this method from my java code using java_signature the
method_test calls another method which is at the following location

Module1
  Module2
    MyClass
def method_to_call
end
    end
  end
end
when calling from java code it gives error as
Caused by: org.jruby.exceptions.RaiseException: (NameError)
uninitialized constant Module1::Module2::Class
0fd9c7f99b996ea1550f5a78dc35254c?d=identicon&s=25 Sumit Parkhani (sumitparkhani)
on 2013-12-26 13:27
Charles Monteiro wrote in post #1131619:
> at first glance that just sounds like you have not required the file in
> question i.e. require or require_relative but you dont provide enough
> context
>
> Charles

Hi,
thanks Charles  for the quick response ya the name of modules and
classes start
with capital letters.

here's the scenario
First part is i have a class which is locate at
Module1
   Module2
     Module3
       MyClass
     end
 def method_test
end
   end
  end
 end

I am calling this method from my java code using java_signature the
method_test calls another method which is at the following location

Module1
  Module2
    MyClass
def method_to_call
end
    end
  end
end
when calling from java code it gives error as
Caused by: org.jruby.exceptions.RaiseException: (NameError)
uninitialized constant Module1::Module2::Class
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.