Issue Details (XML | Word | Printable)

Key: JRUBY-2599
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Charles Oliver Nutter
Reporter: Chris Schneider
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
JRuby

Sinatra Web Framework fails on rendering ERB while MRI works - LocalJumpError - yield called out of block

Created: 31/May/08 04:16 PM   Updated: 10/Sep/08 06:48 PM
Component/s: Core Classes/Modules
Affects Version/s: None
Fix Version/s: JRuby 1.1.3

Time Tracking:
Not Specified

File Attachments: 1. GZip Archive jruby_sinatra_jumperror.tar.gz (148 kB)

Environment: Windows Vista
Sinatra Edge as of 5/31/2007 (http://github.com/bmizerany/sinatra/tree/master)

64 Bit version of Java

$ java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
Issue Links:
Related
 


 Description  « Hide
See the Sinatra bug report at: http://sinatra.lighthouseapp.com/projects/9779/tickets/24-running-on-jruby-fails-at-rendering-erb-templates

Copied from the original bug report:

The sinatra app (app.rb):

require '../sinatra/lib/sinatra.rb'

get '/' do
"Hello World"
end

get '/:foo' do
erb :foo
end

The template (views/foo.erb):

<html>
<head></head>
<body>Erb rendered</body>
</html>

The command to run the application:
jruby app.rb

The error:

Params:

{"foo"=>"blah"}

LocalJumpError - yield called out of block

The working part:
Going to '/' returns "Hello World" just as expected. Using a Haml renderer works fine as well.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Chris Schneider added a comment - 31/May/08 04:52 PM
On further investigation, it appears I have a rouge layout in the views directory that I didn't notice. I only had one for erb, and not for haml, which mislead me to think that Erb was the problem.

It appears that layouts in general are the issue, and not erb, haml or any other particular renderer. The error remains the same.

views/layout.erb
------
<html>
<head></head>
<body>
<p>Layout rendered</p>
<%= yield %>
</body>
</html>

views/layout.haml
------
%html
%body
#content= yield

views/foo.haml
--------
%p Hello World

Of course to change to using the haml renderer, you have to change the "erb :foo" line to "haml :foo".

Also, as a bit of background for people who haven't seen Sinatra before, basically, you map URLs to actions. The line "get '/:foo' do" sets up a handler for /foo, /bar, /baz and so on. The :foo part denotes a variable that can be accessed via params[:foo], this feature is not used here. I realize that there might be a bit of confusion by my repeated use of "foo".


Charles Oliver Nutter added a comment - 31/May/08 05:06 PM
Would it be possible to get a small packaged app we can run to make repeat this failure?

Vladimir Sizikov added a comment - 02/Jun/08 12:47 PM
OK, I've figured what's the problem. And indeed this is a JRuby issue with eval'ing 'yield' to the supplied block/binding.

See JRUBY-2605 for more detail.


Chris Schneider added a comment - 03/Jun/08 09:28 PM
An example sinatra application (including the edge sinatra library as of writing).

This does rely on mongrel to run, and haml to run the haml examples.

Just point ruby at thingy.rb and then point your browser at http://localhost:4567/erb or /haml to see the problem, and at /no_layout to see it work fine with no layout.


Charles Oliver Nutter added a comment - 04/Jun/08 10:55 AM
JRUBY-2605 has been fixed, so hopefully this issue is soon to be resolved.

Vladimir Sizikov added a comment - 04/Jun/08 11:01 AM
Indeed, as soon as eval thing was fixed, this is fixed as well, I verified that, and Sinatra now works just fine.