By Developers, For Developers

Historical errata for Using JRuby

PDF PgPaper PgTypeDescriptionFixed onComments
17TYPO

Section 1.6, second paragraph, second line, should read:

JRuby allows you to compile your Ruby code…

2010-06-18
147SUGGEST

This set of Rake tasks gives us enough to build the .jar file:
$ jruby -S rake unpack_gems

—> I believe this should read
$ jruby -S rake small_jar

2010-07-02Thanks! We've fixed this for B4.0.
198TYPO

first paragraph, the sentence before the last sentence starts with “Snce”, should read Since

2010-07-02Thanks! The fix is targeted for B4.0.
201TYPO

“Remember, this classes are objects, too”
should be
“Remember, classes are objects, too”

2010-07-02Good catch, thanks! We should have a fix in B4.0.
37SUGGEST

Array::ArrayDemo.combine_strings([“foo” , “bar” , “baz” ]) already worked in v1.5.1 (no need for to_java?)

2010-07-02Indeed, as of JRuby 1.5, this code no longer throws an error. We've reworked the example and explanation for B4.0. Thanks for reporting this.
72TYPO

The word “several” is misspelled as “severeal.”

2010-07-29
78ERROR

The output at the top of p.78 was generated from the wrong run of the compiler. The correct output looks similar, but the missing symbol should be the constructor for “waveform,” not the class itself. (The description in the text is correct.)

2010-07-29
33ERROR

Attempting to run example code from the website; received the following error:

[~/jrubybook] jruby -J-Xss128m ackerizer.rb
/Users/cscott/local/jruby/lib/ruby/gems/1.8/gems/rubeus-0.0.7-java/lib/rubeus/awt/attributes.rb:22:in `new_with_attributes’: stack level too deep (SystemStackError)
\tfrom /Users/cscott/local/jruby/lib/ruby/gems/1.8/gems/rubeus-0.0.7-java/lib/rubeus/awt/attributes.rb:19:in `each’
\tfrom /Users/cscott/local/jruby/lib/ruby/gems/1.8/gems/rubeus-0.0.7-java/lib/rubeus/awt/attributes.rb:19:in `new_with_attributes’
\tfrom /Users/cscott/local/jruby/lib/ruby/gems/1.8/gems/rubeus-0.0.7-java/lib/rubeus/awt/nestable.rb:50:in `new_with_nestable’
\tfrom ackerizer.rb:23

2010-05-07The 0.0.7 version of Rubeus needed a patch to run this example. Upgrading to 0.0.9 (by doing a "jruby -S gem install rubeus") should fix the issue.
63SUGGEST

I’m guessing this is a “me” problem and not erratum. But might need clarification in the book…

But for some reason when I build the historian project with ant it can find the org.jruby.embed package:

-do-compile:
[javac] Compiling 11 source files to /Users/todcrone/work/jruby/code/ruby_from_java/historian/build/classes
[javac] /Users/todcrone/work/jruby/code/ruby_from_java/historian/src/book/embed/Historian1.java:13: package org.jruby.embed does not exist
[javac] import org.jruby.embed.InvokeFailedException;
[javac] ^
[javac] /Users/todcrone/work/jruby/code/ruby_from_java/historian/src/book/embed/Historian1.java:14: package org.jruby.embed does not exist
[javac] import org.jruby.embed.ScriptingContainer;

I have jruby 1.5.3 which I thought included that package already. What am I missing?

2010-10-29
63SUGGEST

Sorry…I’m stupid but some other readers might be as well. I downloaded jruby-complete-XXX.jar and moved to the historian /lib directory with name jruby-complete.jar per the build.properties in the nbproject folder. I had assumed the downloaded code had everything ready to go. If the book mentioned this, perhaps it should be clarified.

2010-10-21You're right; we should explain the need to download the .jar file. We've added a "get-jruby-libs" command to the "bin" directory to download this file into the right place, and the chapter now explains how to use this command. \n \nGood catch; thanks! \n
208SUGGEST

Didn’t see a line for installing the gem for “shoulda”. Initially thought it might be included by default since others had lines for installing the gem right after intro.

$ jruby -S gem install shoulda

2010-10-29Good catch! We'll add this to the final version. Thanks!
38ERROR

I too am having difficulties running the ackerizer.rb example on page 38. I am using Windows 7, jruby 1.5.2. The error is as follows:

C:\\Users\\andrew\\projects\\jruby\\java_from_ruby>jruby -J-Xss128m ackerizer.rb
java/lang/Thread.java:–2:in `start0’: java.lang.OutOfMemoryError: unable to crea
te new native thread (NativeException)
from java/lang/Thread.java:597:in `start’
from sun/awt/windows/WToolkit.java:246:in `
from sun/reflect/NativeConstructorAccessorImpl.java:–2:in `newInstance0’

from sun/reflect/NativeConstructorAccessorImpl.java:39:in `newInstance’
from sun/reflect/DelegatingConstructorAccessorImpl.java:27:in `newInstan
ce’
from java/lang/reflect/Constructor.java:513:in `newInstance’
from java/lang/Class.java:355:in `newInstance0’
from java/lang/Class.java:308:in `newInstance’
… 17 levels…
from C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/gems/rubeus-0.0.9-java/lib/r
ubeus/awt/attributes.rb:14:in `new_with_attributes’
from C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/gems/rubeus-0.0.9-java/lib/r
ubeus/awt/nestable.rb:50:in `new_with_nestable’
from ackerizer.rb:23

If I remove the J-Xss128m flag from the command line, the GUI starts, but it dies with this error when I try and press the> button:

C:\\Users\\andrew\\projects\\jruby\\java_from_ruby>jruby ackerizer.rb
Exception in thread “AWT-EventQueue-0” C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/ge
ms/rubeus-0.0.9-java/lib/rubeus/awt/event.rb:79:in `listen’: stack level too dee
p (SystemStackError)
from C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/gems/rubeus-0.0.9-java/lib/r
ubeus/awt/event.rb:90:in `call’
from C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/gems/rubeus-0.0.9-java/lib/r
ubeus/awt/event.rb:90:in `actionPerformed’
from :1
…internal jruby stack elided…
from Rubeus::Awt::Event.listen(C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/ge
ms/rubeus-0.0.9-java/lib/rubeus/awt/event.rb:90)
from Proc.call(C:/jruby/jruby-1.5.2/lib/ruby/gems/1.8/gems/rubeus-0.0.9-
java/lib/rubeus/awt/event.rb:90)
from #.actionPerformed(:1)
from (unknown).(unknown)(:1)

2010-10-29Indeed, it looks like on the latest version of JRuby, a stack size of 64m is much more likely to work across platforms. Thanks for bringing this to our attention.
109SUGGEST

I think you are aware of an issue using JRuby 1.5.5 and Rails 3.0.3 but might make mention or make sure the reader is using newer version of JRuby (from git or release 1.5.6).

243SUGGEST

Last line “Next install the Monkeybars gem…” would read better if it were in a new paragraph. At the moment, this gives the impression it’s a netbeans step. Probably this is made worse by the fact the gem install spans a page break.

38TYPO

The last paragraph on page 38 has two sentences repeated at the top of page 39.

58SUGGEST

Question I had reading this: does the become_java! method described earlier help at all with the “lost monkeypatches” problem? Or does it only apply to classes, not objects?

226SUGGEST

I have had a great deal of trouble getting JTestR to work for my project. With the config from the book (0.6) I get:

[INFO] Internal error in the plugin manager executing goal ‘org.jtestr:jtestr:0.6:test’: Unable to load the mojo ‘org.jtestr:jtestr:0.6:test’ in the plugin ‘org.jtestr:jtestr’. A required class is missing: org/jruby/exceptions/RaiseException

Is this something that could be easily avoided with a couple lines of clarification?

169TYPO

In the first ant example the name of the target (‘hello_from_ant’) does not correspond with the default target name (‘hello’), so calling ‘ant’ without an explicit target argument won’t work. Just rename the target to ‘hello’ or the default to ‘hello_from_ant’.

106SUGGEST

There’s a much better way to do platform detection for Jruby and regular ruby

You can say:

platforms :jruby do
gem ‘activerecord-jdbc-adapter’
gem ‘jdbc-sqlite3’
end

platforms :ruby do
gem ‘sqlite3-ruby’
end

This works when the JRUBY_VERSION environment variable isn’t defined, as when using RVM. It works in rails 3.0.3 out of experience.

126TYPO

When generating the scaffold for Review, the first — argument should be —migration, not —migrate. If using —migrate, the error at the command line will be prefixed with ‘Another migration is already named create_reviews’

155ERROR

Building Ribs using the current version of rspec (2.5.0 as it type this), as installed by the previous commands, will fail as the Rakefile assumes the build will use version 1 of rspec.

The git diff is as following:
diff —git a/Rakefile b/Rakefile
index 2317c71..1ae0ff0 100644
—- a/Rakefile
+ b/Rakefile
@@ –1,7 +1,7 @@
require ‘rubygems’
diff —git a/Rakefile b/Rakefile
index 2317c71..1ae0ff0 100644
—- a/Rakefile
+ b/Rakefile
@@ –1,7 +1,7 @@
require ‘rubygems’
require ‘rake/gempackagetask’
require ‘rake/rdoctask’
-require ‘spec/rake/spectask’
+require ‘rspec/core/rake_task’

task :ant do
ret = system(‘ant’)
@@ –19,12 +19,10 @@ task :flog do
end

desc “Run all specs”
-Spec::Rake::SpecTask.new(:spec) do |t|

- t.libs << “test”

- t.libs << “lib”

- t.spec_files = FileList[‘test//*_spec.rb’]
+RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = true
- t.spec_opts = [“-fs”, “—color”]
+ t.rspec_opts = [“-fs”, “—color”]
+ t.pattern = ‘test//*_spec.rb’
end

task :spec => [:ant]

83TYPO

“and long-running programs well seem” should be “and long-running programs will seem”

64ERROR

Issuing the command `ant`, the `do_compile` step fails due to not finding the jruby embed package.

I have issued this before running `ant`, just to make sure:

export CLASSPATH=$CLASSPATH:/Users/me/.rvm/rubies/jruby-1.6.4/lib/jruby.jar

44ERROR

url.get_protocol # Isn’t assigned.

url = URL.new ‘http’, ‘pragprog.com’, ‘/titles’ # FIFY

44SUGGEST

attributes.rb doesn’t really make sense to have a code example for, seeing as it’s purely for users to digest and not actually run.

68SUGGEST

Referring to ruby methods as functions and then again as methods is somewhat confusing. I suggest referring to ruby methods as methods and java functions as functions to keep things clear.

“While we’re at it, we’ll move the function into a class:”

“So far, we’ve been calling the history method by building up a string in Java with the word history in it. But JRuby can actually call the method directly, using the callMethod( ) operation.”

261ERROR

Command to launch limelight demos does not work:
book says “jruby -S limelight open”
but I haven’t been able to figure out what the correct command is yet, tried:
jruby -S limelight open productions/playbills
but no luck.
Using jruby-1.7.4, limelight (0.6.19 java)
Error msg starts with:
WARNING 14:55:22:465 : Boot - OS class could not be loaded
WARNING 14:55:22:468 : java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)…

250ERROR

Error installing monkeybars.
Book says “jruby -S gem install monkeybars rawr” but neither is found in any repository.
Installed rawr like this:
jruby -S gem install rawr —source http: //gems.neurogami.com
then downloaded monkeybars (1.0.4) gem locally to install.
Using jruby 1.7.4.

Categories: