Forum: JRuby Problem with Eventmachine

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joseph A. (Guest)
on 2009-05-09 18:06
(Received via mailing list)
I'm trying to use the Juggernaut http://juggernaut.rubyforge.org/ gem
for a
project and would like to use JRuby.  It depends on the JSON and
Eventmachine gems.  The JSON gem uses a native extension, but they also
have
a pure ruby version so I changed Juggernaut to depend on the pure ruby
version instead which works fine now.  But now I'm having a problem with
Eventmachine.
This is the exception I get when trying to access the Juggernaut server:

arthman:railpro jjathman$ jruby -S juggernaut -c juggernaut.yml
Starting Juggernaut server on port: 5001...
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../lib/juggernaut/server.rb:369:in
`client_ip': undefined method `get_peername' for EventMachine:Module
(NoMethodError)
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../lib/juggernaut/server.rb:59:in
`post_init'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/eventmachine.rb:1453:in
`new'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/eventmachine.rb:1446:in
`instance_eval'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/eventmachine.rb:1446:in
`new'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/eventmachine.rb:1269:in
`event_callback'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/jeventmachine.rb:49:in
`eventCallback'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/jeventmachine.rb:67:in
`run_machine'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.6-java/lib/eventmachine.rb:240:in
`run'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../lib/juggernaut/runner.rb:72:in
`start'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../lib/juggernaut/runner.rb:48:in
`initialize'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../lib/juggernaut/runner.rb:11:in
`run'
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/juggernaut:4
from
/Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/juggernaut:19:in
`load'
from /Users/jjathman/jruby/bin/juggernaut:19


But from what I can see it sure looks like there is a get_peername
method
defined in the JRuby version of the event machine gem.  Anyone have any
ideas what's going on?  Thanks.

Joe
Chuck R. (Guest)
on 2009-05-09 18:28
(Received via mailing list)
On May 9, 2009, at 9:05 AM, Joseph A. wrote:

> arthman:railpro jjathman$ jruby -S juggernaut -c juggernaut.yml
> Starting Juggernaut server on port: 5001...
> /Users/jjathman/jruby/lib/ruby/gems/1.8/gems/juggernaut-0.5.7/bin/../
> lib/juggernaut/server.rb:369:in `client_ip': undefined method
> `get_peername' for EventMachine:Module (NoMethodError)

<guess>
You are using the pure ruby eventmachine reactor since you don't have
the java reactor built. If you installed as a gem, go to your
eventmachine gem directory and run 'rake build:java' so that the
proper jars get built and installed. Then try again. (Make sure you
run "sudo <command>" if your gems are installed as root.)
</guess>

cr
Joseph A. (Guest)
on 2009-05-09 19:39
(Received via mailing list)
Thanks for the tip, but this didn't seem to help, still get the same
exception.  From what I can see I don't think this is a problem with the
Java part of the gem.  It looks like the EventMachine::Connection class
does
define the "get_peername" method, I don't understand why I'm getting the
NoMethodError.  It's defined in eventmachine.rb on line 1765.
Joe
Chuck R. (Guest)
on 2009-05-09 23:34
(Received via mailing list)
On May 9, 2009, at 10:39 AM, Joseph A. wrote:

> Thanks for the tip, but this didn't seem to help, still get the same
> exception.  From what I can see I don't think this is a problem with
> the Java part of the gem.  It looks like the
> EventMachine::Connection class does define the "get_peername"
> method, I don't understand why I'm getting the NoMethodError.  It's
> defined in eventmachine.rb on line 1765.
>

Weird, my eventmachine.rb file is only 1622 lines long.

Anyway, I looked a little closer at this. There is a #get_peername
method defined in the pure ruby reactor and in the C reactor. I
searched for "peername" and found this comment in the java source.

  public final void testBindConnect() throws IOException {
    class Server extends Connection {
      public void postInit() {
        // TODO: get peername here and check if the port is 33333
        // doesnt seem like peername is impl yet?
        System.out.println("post init!");
      }
    };
  ....

So, there is no #get_peername defined in the java reactor yet. I
suggest going to rubyeventmachine.com and filing a bug. You might also
want to join the eventmachine mailing list since this is an
eventmachine-specific issue and doesn't have much to do with jruby.

In the interim, force jruby to use the pure ruby version of the
reactor and you might get a bit further.

cr


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.