Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(NameError) uninitialized constant Java::BacktypeStorm::Config::CONFIG #7

Closed
stonegao opened this issue Dec 12, 2011 · 4 comments
Closed

Comments

@stonegao
Copy link
Contributor

Tried redstorm with other extra gems dependencies (Mongoid, Resque), I start topology using the following command:

RACK_ENV=development redstorm local lib/redstorm-topology/event_topology.rb

But it throw uninitialized constant Java::BacktypeStorm::Config::CONFIG error. Also I am using Mac OS X but the JRuby stack trace has some weird lines related with WIN32API:

launching java -cp "/Users/stone/code/redstorm-topology/target/classes:/Users/stone/code/redstorm-topology/target/dependency/*" redstorm.TopologyLauncher local lib/redstorm-topology/event_topology.rb
file:/Users/stone/code/redstorm-topology/target/dependency/jruby-complete-1.6.5.jar!/builtin/javasupport/core_ext/object.rb:99 warning: already initialized constant Config
RedStorm v0.2.1 starting topology EventTopology in local environment
1    [main] ERROR org.apache.zookeeper.server.NIOServerCnxn  - Thread Thread[main,5,main] died
org.jruby.exceptions.RaiseException: (NameError) uninitialized constant Java::BacktypeStorm::Config::CONFIG
    at org.jruby.RubyModule.const_missing(org/jruby/RubyModule.java:2590)
    at #.(root)(file:/Users/stone/code/redstorm-topology/target/dependency/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/Win32API.rb:2)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.Dir(file:/Users/stone/code/redstorm-topology/target/dependency/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/Win32API.rb:14)
    at #.(root)(file:/Users/stone/code/redstorm-topology/target/dependency/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/1.8/tmpdir.rb:9)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(file:/Users/stone/code/redstorm-topology/target/dependency/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/1.8/tmpdir.rb:5)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(/Users/stone/.rvm/gems/jruby-1.6.5/gems/rack-1.2.4/lib/rack/utils.rb:1)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(/Users/stone/.rvm/gems/jruby-1.6.5/gems/rack-1.2.4/lib/rack/request.rb:3)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(/Users/stone/.rvm/gems/jruby-1.6.5/gems/rack-1.2.4/lib/rack/showexceptions.rb:1)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(/Users/stone/.rvm/gems/jruby-1.6.5/gems/sinatra-1.2.7/lib/sinatra/showexceptions.rb:6)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at #.(root)(/Users/stone/.rvm/gems/jruby-1.6.5/gems/sinatra-1.2.7/lib/sinatra/base.rb:1)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at Bundler::Runtime.require(/Users/stone/.rvm/gems/jruby-1.6.5/gems/resque-1.19.0/lib/resque/server.rb:68)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1612)
    at Bundler::Runtime.require(/Users/stone/.rvm/gems/jruby-1.6.5/gems/bundler-1.0.21/lib/bundler/runtime.rb:66)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1612)
    at Bundler::Runtime.require(/Users/stone/.rvm/gems/jruby-1.6.5/gems/bundler-1.0.21/lib/bundler/runtime.rb:55)
    at #.require(/Users/stone/.rvm/gems/jruby-1.6.5/gems/bundler-1.0.21/lib/bundler.rb:122)
    at #.(root)(/Users/stone/code/redstorm-topology/lib/redstorm-topology/boot.rb:17)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at Kernel.require(/Users/stone/code/redstorm-topology/lib/redstorm-topology/boot.rb:55)
    at #.(root)(./lib/redstorm-topology/event_topology.rb:4)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
    at Kernel.require(./lib/redstorm-topology/event_topology.rb:55)
    at #.main(/Users/stone/.rvm/gems/jruby-1.6.5/gems/redstorm-0.2.1/lib/red_storm/topology_launcher.rb:42)

I am using Bundler to manage gem dependencies, boot.rb is just copy & paste from rails:

require 'rubygems'

# Set up gems listed in the Gemfile.
PROJECT_ROOT = File.expand_path('../../..', __FILE__)

gemfile = File.join(PROJECT_ROOT, 'Gemfile')
begin
  ENV['BUNDLE_GEMFILE'] = gemfile
  require 'bundler'
  Bundler.setup
rescue Bundler::GemNotFound => e
  STDERR.puts e.message
  STDERR.puts "Try running `bundle install`."
  exit!
end if File.exist?(gemfile)

Bundler.require(:default)

BTW: I think it's great if you can create a redstorm starter project to demonstrate the project source code layout, how to manage dependencies and how to using JRuby with Java together to develop storm topologies. (redstorm it's self is a great example, but another one which focus on the usage of redstorm is awesome).

Thanks for your help

Stone

@colinsurprenant
Copy link
Owner

Hi Stone,

I am not sure I understand what you are trying to do here. It seems you are trying to use RedStorm from within Rails? I did not test RedStorm with Rail nor Bundler. Check the RedStorm README for instructions on how to use gems with RedStorm.

I think you should try to keep your RedStorm project separate from Rails. Is there any specific reason for this? Do you need to share Rails code (models?)

Colin

@stonegao
Copy link
Contributor Author

Hi Colin,

Sorry for the confusion.

I am not using redstorm from within Rails. I setup a sperate project and the aforementioned boot.rb is borrowed from a Rails project, because I don't want require libs explicitly in my code.

Finally I figured out the problem: in Gemfile of the redstorm project, there's one line like following :

gem "resque", :require => "resque/server"

And this line caused the weird uninitialized constant Java::BacktypeStorm::Config::CONFIG error. After changing that line to:

gem "resque"

Bundler works like a charm now with redstorm. (But the error message of JRuby is indeed confusing and weird)

RedStorm README suggested put gems in target/gems/, since Bundler works well with redstorm, is it possible for redstorm to use Bundler managing gems and puts them in vendor/cache ?

Stone

@colinsurprenant
Copy link
Owner

Ok! Sure, making RedStorm work with bundler is on my todo. Btw, using bundler like this will work using the local cluster but will not work on a remote production cluster unless the gems are installed in target/gems. For gem to be available on the remote production servers, they must be packaged into the "production" jar file.

jondot added a commit to jondot/redstorm that referenced this issue May 19, 2012
Look like java_import was introducing a class overwrite for 'Config',
when `rbconfig` needed to be used (Config::CONFIG), the error would surface.

rbconfig is used with rack utils.
@jondot
Copy link
Contributor

jondot commented May 19, 2012

@stonegao please check out my pull request. there's a good chance that the original cause wasn't the require statement that you found.
hope it helps.

colinsurprenant added a commit that referenced this issue May 29, 2012
Fixed real cause of issue #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants