Generic-user-small Jeff Morgan 3 posts

I just installed jruby and all suggested gems. When I try to run
the app using ‘jruby junquenote_app.rb’ I get the stacktrace below.
When I try to run the shell script included it just hangs. I am
running OSX. Do you have any idea what I am missing?


/opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/java/builder/util.rb:162:in `get_listener_info': undefined method `java_instance_methods' for nil:NilClass (NoMethodError)
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/java/builder/main.rb:252:in `consume'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/main.rb:547:in `consume'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/main.rb:546:in `each'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/main.rb:546:in `consume'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/context.rb:481:in `csm'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/context.rb:225:in `send'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/main.rb:115:in `method_missing'
    from junquenote_app.rb:42:in `initialize'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/context.rb:293:in `call'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/context.rb:293:in `call'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/base.rb:208:in `call'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/java/builder/main.rb:82:in `run'
    from /opt/jruby/lib/ruby/gems/1.8/gems/cheri-0.0.9/lib/cheri/builder/context.rb:247:in `msend'
    from (eval):2:in `frame'
    from junquenote_app.rb:38:in `initialize'
    from junquenote_app.rb:263

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, Jeff.

The shell script is just a wrapper around the jruby binary with a couple of Mac-specific flags turned on, so that the menu bar and dock icon have more descriptive names in them. Like jruby, it waits for user input when you run it with no arguments. Ctrl+D should get you out of there.

Either running ./jruby_mac.sh junquenote_app.rb, or just jruby junquenote_app.rb, should launch the JunqueNote window.

What versions of JRuby and OS X are you running? I’ll try to replicate your setup as closely as I can here.

—Ian

 
Generic-user-small Jeff Morgan 3 posts

Ian,

When I ran the mac script as noted I got the same stacktrace. I am using jruby
verion 1.1.3, ruby 1.8.6 patchlevel 114, and an up to date leopard 10.5.4. Here
is a list of my current jruby gems:

actionmailer (2.1.0)
actionpack (2.1.0)
activerecord (2.1.0)
activerecord-jdbc-adapter (0.8.2)
activerecord-jdbcmysql-adapter (0.8.2)
activeresource (2.1.0)
activesupport (2.1.0)
cheri (0.0.9)
crypt (1.1.4)
gem_plugin (0.2.3)
jdbc-mysql (5.0.4)
mongrel (1.1.5)
rails (2.1.0)
rake (0.8.1)
sources (0.0.1)

 
Generic-user-small Jeff Morgan 3 posts

I tried to run the app on my Windows VM after installing jruby and it worked fine.
The problem seems to be related to running it on OSX.

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, Jeff.

Glad to hear the example’s running okay. Sorry about the extra step needed with the VM. If you’d still like to pursue getting this running on just Leopard, the next thing I’d try would be to use a clean copy of JRuby 1.1.3, something like this (taken from my .bash_history on an Intel iMac running 10.5.4):

I also tried installing the same set of gems and versions listed above, and couldn’t repeat the failure here. One thing that would be interesting would be to see if one of the demo apps from the Cheri website works at all:

require 'rubygems'
require 'cheri/swing'
include Cheri::Swing

f = swing.frame('Hello World') { label 'Hello!' }
f.pack
f.visible = true
 
Generic-user-small gb 5 posts

So I followed the steps above which got finally got the junque note working. but now I can’t seem to install any gems into the normal ruby installation . it seems keep pointing to jRUBY
which isn’t compatible.

sudo gem install rb-appscript
Building native extensions. This could take a while…
/opt/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError) from /opt/jruby/lib/ruby/1.8/mkmf.rb:31:in `require’ from extconf.rb:31
ERROR: Error installing rb-appscript: ERROR: Failed to build gem native extension.

/opt/jruby/bin/jruby extconf.rb install rb-appscript

Gem files will remain installed in /opt/jruby/lib/ruby/gems/1.8/gems/rb-appscript-0.5.1 for inspection.
Results logged to /opt/jruby/lib/ruby/gems/1.8/gems/rb-appscript-0.5.1/gem_make.out

any ideas on how to fix this without breaking the JRuby stuff ?
thanks
g

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, gb.

There are a couple of ways to handle this. One is to use two different Terminal windows / tabs, only one of which has your JRuby directory in the $PATH. Another is to put your JRuby directory (e.g., /opt/jruby/bin) at the very end of your $PATH, and to prefix Ruby binary names like gem, rake, etc., with jruby -S, e.g., sudo jruby -S gem install cheri when you want to use the JRuby versions.

—Ian

 
Xing_small Mareike Hybsier 1 post

Unfortunately, I get the same errors like Jeff Morgan in the first post, running Mac OS X 10.4.11 and JRuby 1.1.4. So did someone find a solution for that—except switching the os?

BTW: The code of the cheri demo app posted above works fine.


Okay, I found the troublemaker. It is the following statement:

on_window_closing { ... }

Maybe it has something to do with Mac OS X’s own implementation of the window controls.

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, Mareike.

Nice sleuthing! I’m not sure why on_window_closing is throwing an error on some Macs, but at least the possibility of a workaround is open now. I’ll see how many of the tests will still be meaningful if we skip using this hook.

—Ian

 
Generic-user-small Del Ben Oscar 1 post

Same problem here, i’ve commented on_window_closing and now it works

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, everyone.

Success! I was finally able to replicate the crash. The “fancy hello world” example from the Cheri website (which also uses on_window_closing) exhibits the behavior on this machine as well. I’ve posted a ticket to the Cheri tracker, and will see if I can get them a little more specific information about where this is happening.

In the meantime, as Mareike has noted, commenting out the on_window_closing will stop the error backtrace. But a couple of the tests will now report failures, because they’re clicking on the Close button of an unsaved document but not seeing any save prompts.

Fortunately, we can close the window by using the File >> Exit menu item instead. That code lives in the Note class, which means it has implications across platforms.

I’ve packaged up a patch affecting the simplify and home_stretch chapter directories. Save the file in your code directory as cheri-fix.patch, and then execute the following command from the code directory:

patch -p1 < cheri-fix.patch

Or if you prefer, you can download the entire source archive with the patch already applied.

UPDATE The official download site on pragprog.com has the updated code now, so the external patch link is now unnecessary.

 
Photo_small Tom Ayerst 4 posts

Same thing happened to me on Windows XP running jruby 1.1.4 on java 6. I cannot install the patch (Ian’s site is blocked from here :-( ) but commenting out the on_window_closing line works.

 
Generic-user-small Mark Wilden 1 post

Please update both archive formats, so that someone who unsuccessfully tried to follow the link in the book, then found the source folder manually, then downloaded the tarball, then found it crashes doesn’t have to waste their time.

 
2201682121_40eda4245f_o_small Ian Dees 26 posts

Hi, Mark.

I was hoping the Cheri issue would be a quick fix, but you’re right—if we update the source archives, then people won’t have to wait for that fix. I’ve put the wheels in motion to get new archives up.

—Ian

UPDATE They’re up.

14 posts, 7 voices