Hi all,

I tested JRuby trunk on Rails 2.0 PRE1 with an JRoR application which uses ActiveResource, and found some weird behavior.

First of all, download the application from http://ias.springnote.com/pages/512602/attachments/226453 (or open http://ias.springnote.com/pages/512602.xhtml and click rails2_ares_test.zip link)

Next, unzip it and run "jruby script/server".

Access http://localhost:3000/ with your browser and you can see a list. This causes "Page" resource to do "find :all", which works fine.

Meanwhile, access http://localhost:3000/pages/4434 and you might see

Home

or the following error message:
---
 NoMethodError in PagesController#show

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.attributes

RAILS_ROOT: /Volumes/FLASHBACK/workspace/rails2_ares_test
Application Trace | Framework Trace | Full Trace

vendor/rails/activesupport/lib/active_support/vendor/xml_simple.rb: 708:in `get_attributes' vendor/rails/activesupport/lib/active_support/vendor/xml_simple.rb: 462:in `collapse' vendor/rails/activesupport/lib/active_support/core_ext/hash/ conversions.rb:30:in `xml_in_string' vendor/rails/activesupport/lib/active_support/core_ext/hash/ conversions.rb:40:in `xml_in_string' vendor/rails/activesupport/lib/active_support/core_ext/hash/ conversions.rb:159:in `from_xml' vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb: 19:in `decode' vendor/rails/activeresource/lib/active_resource/connection.rb:74:in `get' vendor/rails/activeresource/lib/active_resource/base.rb:461:in `find_single'
vendor/rails/activeresource/lib/active_resource/base.rb:388:in `find'
app/controllers/pages_controller.rb:3:in `show'
...
---

If you see either "Home" or the error message, please repeat refreshing your browser with F5 or CTRL(Command)+R, then you can see the other result. In case the error occurs, connection.rb shows that status 200 and length 0 in its info logging.

I tested this application with MRI and it worked well with both http://localhost:3000/pages and http://localhost:3000/pages/4434

What I guess about this discrepancy is that HTTPS connection in JRuby may have some problem.

Thanks in advance for your help,

ias

Reply via email to