Nick Sieger: Introducing JRuby-Rack http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack en-us 40 "Introducing JRuby-Rack" by Otto Hilska <p>I&#8217;ve already got this working with JRuby + Merb + Glassfish. See <a href='http://blog.nodeta.fi/2008/05/22/living-on-the-edge-jruby-merb-glassfish/' rel="nofollow">http://blog.nodeta.fi/2008/05/22/living-on-the-edge-jruby-merb-glassfish/</a> for more information.</p> Fri, 23 May 2008 06:26:21 +0000 urn:uuid:3e13daac-5120-47d6-8817-b9a1ad7784a9 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-417 "Introducing JRuby-Rack" by Irfan Baig <p>I can confirm Rich&#8217;s problem in Resin too</p> Wed, 14 May 2008 22:45:27 +0000 urn:uuid:dadaabb7-1718-4a4d-af9c-d49ed49fe473 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-415 "Introducing JRuby-Rack" by Nick <p>@kim: sorry to hear that. These are the kinds of bugs that obviously need to be fleshed out with wider use. Is there nothing in the tomcat logs/catalina.out file? If application initialization failed, there should definitely be something in it.</p> <p>Can you try dropping in this debug build? I&#8217;ve added a few extra exception rescue-and-dump clauses that should hopefully make things more visible. Drop <a href='http://caldersphere.net/jruby-rack/jruby-rack-0.9.1-SNAPSHOT.jar' rel="nofollow">this jar</a> in place of the existing one.</p> <p>Also, for anyone who&#8217;s reading and has any more bug reports or feedback, please send them to the <a href='http://xircles.codehaus.org/lists/user%40jruby.codehaus.org' rel="nofollow">jruby-user list</a>.</p> Wed, 14 May 2008 14:24:34 +0000 urn:uuid:ec344d68-1f6a-4138-83e0-bfe368dc3913 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-414 "Introducing JRuby-Rack" by kim <p>As awesome as this sounds, I cannot get it to work on neither tomcat or jetty using a rails app which deploys successfully using warbler 0.9.5 . Additionally, there&#8217;s no log output anywhere &#8211; I just get the rails 500 page.</p> <p>I carefully revisited the new warble.rb options as well as web.xml.erb &#8211; to no avail.</p> <p>Any hints on how to diagnose this?</p> Wed, 14 May 2008 10:49:39 +0000 urn:uuid:962588bf-b3a5-42cb-a30e-37e09b095d7d http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-413 "Introducing JRuby-Rack" by Nick Sieger <p>@Rich: sounds like some differences in how OC4J and Glassfish handle getServletPath/getPathInfo/getRequestURI may be in play. Let&#8217;s work on it in IRC or on the mailing list.</p> <p>@Osman: I don&#8217;t have a simple Rack example out there right now. I&#8217;ll whip one up soon for you.</p> <p>@ab5tract: 1) This is not tied to Glassfish (or the GF v3 gem) specifically. It works off of the Java Servlet spec, so should work for any appserver. 2) Warbler is secretly able to war other apps as well, though I just barely introduced this functionality so I haven&#8217;t documented it yet. If you look in the newly generated config/warble.rb you might get a clue. The example I&#8217;ll work up for Osman should help for you too.</p> Mon, 12 May 2008 22:00:43 +0000 urn:uuid:0179473f-3135-435b-b45e-2e64363cc1d5 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-412 "Introducing JRuby-Rack" by ab5tract <p>Awesome, I was just complaining about the &#8220;lack of Rack&#8221; to the glassfish mailing list. No one responded though :(</p> <p>2 questions: 1) You do not mention Glassfish. How do they tie together? Is jruby-rack a replacement for goldspike? It seems strange to omit GF, since it looks very likely to become dominant in JRuby web app deployments. 2) Why is Warbler said to be for &#8220;wrapping a Rails app&#8221; in a .war? Why tie it to one framework? Is it secretly modular enough to .war other web apps?</p> <p>I just want a way for to deploy my Waves app without bothering with the mess. Thanks for bringing the community one step closer to achieving point-and-click Rack app deploys!</p> Mon, 12 May 2008 19:26:25 +0000 urn:uuid:c19a9775-4571-4239-b33e-f1307fc64637 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-411 "Introducing JRuby-Rack" by Aslak Hellesøy <p>Thanks so much Nick! This couldn&#8217;t have come at a better time!</p> Mon, 12 May 2008 14:07:44 +0000 urn:uuid:5b03451d-32a5-489c-84de-e0cf17766883 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-410 "Introducing JRuby-Rack" by Osman İzbat <p>Hi.</p> <p>I&#8217;m trying to run a simple rack application with jruby-rack:</p> <p>class HelloWorld def call(env) [200, {&#8220;Content-Type&#8221; => &#8220;text/plain&#8221;}, [&#8220;Hello world!&#8221;]] end end</p> <p>But i coulnd&#8217;t figure out how should i configure my web.xml and where to put hello.rb file that contains above code.</p> Sun, 11 May 2008 21:11:13 +0000 urn:uuid:33cc0941-2608-429b-adac-528feca72b3d http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-409 "Introducing JRuby-Rack" by Stephen Bannasch Probably a buildr problem but I had facets 2.3.0 and 2.4.1 installed and couldn&#8217;t build rack (r159) until I deleted facets v2.4.1. rubygems.rb:140:in `activate&#8217;: can&#8217;t activate facets (= 2.3.0), already activated facets-2.4.1] Sun, 11 May 2008 08:41:43 +0000 urn:uuid:0d127ee8-1cfe-4390-ad38-58ad217528f0 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-408 "Introducing JRuby-Rack" by Tyler Jennings <p>Congratulations Nick! I&#8217;m glad to see the jruby-rack:rails tag in there. We&#8217;ll certainly use it. </p> Fri, 09 May 2008 18:44:36 +0000 urn:uuid:b42abf80-bd4b-45d6-a00d-cba1f2aad239 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-407 "Introducing JRuby-Rack" by Rich Manalang <p>@Nick, one thing I noticed&#8230; rack doesn&#8217;t seem to be picking up requests to the context root (i.e., &#8220;/&#8221; or &#8220;/myapp&#8221; if deployed to a relative context root) &#8211; at least on oc4j. Once I add a relative path within the app it picks up the request, otherwise it thinks I&#8217;m trying to browse the directory. At first I thought it was the filter-mapping, so I changed from url-pattern:/* to *. That didn&#8217;t do it. I also played around with reordering the filter in web.xml &#8211; above the listener and below the listener&#8230; nope.</p> <p>Anyway, I&#8217;ll take a look at your source and compare with goldspike to see if I can find out what&#8217;s going on. BTW, it does work on Jetty.</p> Fri, 09 May 2008 13:55:11 +0000 urn:uuid:d3adc6a9-ff91-4507-a874-e3c154af2b55 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-406 "Introducing JRuby-Rack" by HGH <p>Very cool code.. </p> <p>Thanks! </p> Fri, 09 May 2008 06:07:24 +0000 urn:uuid:5f6cf53a-5cb5-483d-925e-292284a6cba3 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-405 "Introducing JRuby-Rack" by Rich Manalang <p>@Nick, nope. Try it yourself&#8230; the HTTP head sig is different than the servlet error response.</p> Thu, 08 May 2008 23:56:39 +0000 urn:uuid:dba7bf1a-ee7d-4402-b2d3-69d733789c6b http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-404 "Introducing JRuby-Rack" by Nick <p>Rich: Does this work?</p> <div class='typocode'><pre><code class='typocode_ruby '><span class='ident'>render</span> <span class='symbol'>:text</span> <span class='punct'>=&gt;</span> <span class='punct'>&quot;</span><span class='string'>Oracle SSO</span><span class='punct'>&quot;,</span> <span class='symbol'>:status</span> <span class='punct'>=&gt;</span> <span class='number'>499</span></code></pre></div> Thu, 08 May 2008 22:05:14 +0000 urn:uuid:2a0cad53-56bc-4609-b001-934125cf7a3e http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-403 "Introducing JRuby-Rack" by Tom Brice <p>This is the best thing I&#8217;ve seen all year. Thank goodness for JavaOne! Wow. I&#8217;m dreaming of little merb-very-flat or camping apps deployed under a java app container.</p> Thu, 08 May 2008 22:02:45 +0000 urn:uuid:2bf484d0-c201-44dc-a814-b7b33663d0cb http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-402 "Introducing JRuby-Rack" by Ezra Zygmuntowicz <p>Very cool Nick, thanks for working on this! </p> Thu, 08 May 2008 19:53:23 +0000 urn:uuid:991e8eeb-6f1d-42db-9206-6874013f9ccd http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-400 "Introducing JRuby-Rack" by Rich Manalang <p>Excellent. Looks good.</p> <p>One thing&#8230; is the servlet response available too (through rack)? I have this one line of code in our prod app:</p> <p>$java<em>servlet</em>response.send_error(499, &#8220;Oracle SSO&#8221;)</p> <p>I found out that there&#8217;s no way to send an error response in rails so I had to do it through the servlet response. Anyway, just wondering if jruby-rack provides a cleaner way of sending out this response.</p> <p>Rich</p> Thu, 08 May 2008 19:14:02 +0000 urn:uuid:b523430a-c1ec-4796-a9bf-e206b891f256 http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack#comment-399 Introducing JRuby-Rack <p>Continuing in the spirit of Conference-Driven Development, I&#8217;m happy to announce the first public release of <a href="http://wiki.jruby.org/wiki/JRuby_Rack">JRuby-Rack</a>! You can use it to run Rails, Merb, or any Rack-compatible application inside a Java application server.</p> <p>Also released today is <a href="http://caldersphere.rubyforge.org/warbler/">Warbler 0.9.9</a>, which has been updated to bundle JRuby-Rack.</p> <p>In addition to providing as seamless a connection as possible between the servlet environment and Rack, JRuby-Rack (along with Warbler) is also bridging the gap between Ruby and Java web development. Some of the things it does are:</p> <ul> <li>Makes the Java servlet context and servlet request available to Ruby through special variables in the Rack environment</li> <li>Servlet request attributes from Java are passed through and available in the Rack environment. Request attributes can override Rack variables such as <code>PATH_INFO</code>, <code>QUERY_STRING</code> etc.</li> <li>Configures Rails deployment options such as page caching directories and session handling automatically and optimally for the servlet environment.</li> </ul> <p>I&#8217;ve also included the beginnings of some extensions that should help integrate Rails with existing Java web frameworks, servlets, JSPs, and other code. For example, you can invoke a Rails request from within a JSP with a tag:</p> <div class="typocode"><pre><code class="typocode_xml "><span class="punct">&lt;</span><span class="namespace">jruby-rack</span><span class="punct">:</span><span class="tag">rails</span> <span class="attribute">path</span><span class="punct">=&quot;</span><span class="string">/projects/activity</span><span class="punct">&quot;</span> <span class="attribute">params</span><span class="punct">=&quot;</span><span class="string">layout=none</span><span class="punct">&quot;/&gt;</span></code></pre></div> <p>You can set servlet and session attributes and forward to other servlets and JSPs from your Rails controllers:</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">DemoController</span> <span class="punct">&lt;</span> <span class="constant">ApplicationController</span> <span class="keyword">def </span><span class="method">index</span> <span class="ident">servlet_request</span><span class="punct">[&quot;</span><span class="string">hello</span><span class="punct">&quot;]</span> <span class="punct">=</span> <span class="punct">&quot;</span><span class="string">world!</span><span class="punct">&quot;</span> <span class="ident">session</span><span class="punct">[&quot;</span><span class="string">rails</span><span class="punct">&quot;]</span> <span class="punct">=</span> <span class="punct">&quot;</span><span class="string">Visible to java!</span><span class="punct">&quot;</span> <span class="ident">forward_to</span> <span class="punct">&quot;</span><span class="string">/attributes.jsp</span><span class="punct">&quot;</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> <p>and read them from within the servlet or JSP:</p> <div class="typocode"><pre><code class="typocode_xml "><span class="punct">&lt;</span><span class="tag">dl</span><span class="punct">&gt;</span> <span class="punct">&lt;</span><span class="tag">dt</span><span class="punct">&gt;&lt;</span><span class="tag">tt</span><span class="punct">&gt;</span>servlet_request[&quot;hello&quot;] | request.getAttribute(&quot;hello&quot;)<span class="punct">&lt;/</span><span class="tag">tt</span><span class="punct">&gt;&lt;/</span><span class="tag">dt</span><span class="punct">&gt;</span> <span class="punct">&lt;</span><span class="tag">dd</span><span class="punct">&gt;&lt;%=</span> <span class="attribute">request.getAttribute(</span><span class="punct">&quot;</span><span class="string">hello</span><span class="punct">&quot;)</span> %<span class="punct">&gt;&lt;/</span><span class="tag">dd</span><span class="punct">&gt;</span> <span class="punct">&lt;</span><span class="tag">dt</span><span class="punct">&gt;&lt;</span><span class="tag">tt</span><span class="punct">&gt;</span>session[&quot;rails&quot;] | session.getAttribute(&quot;rails&quot;)<span class="punct">&lt;/</span><span class="tag">tt</span><span class="punct">&gt;&lt;/</span><span class="tag">dt</span><span class="punct">&gt;</span> <span class="punct">&lt;</span><span class="tag">dd</span><span class="punct">&gt;&lt;%=</span> <span class="attribute">session.getAttribute(</span><span class="punct">&quot;</span><span class="string">rails</span><span class="punct">&quot;)</span> %<span class="punct">&gt;&lt;/</span><span class="tag">dd</span><span class="punct">&gt;</span> <span class="punct">&lt;/</span><span class="tag">dl</span><span class="punct">&gt;</span></code></pre></div> <p>This is just the beginning of this kind of integration, and I&#8217;m interested where people take it. I think this provides a nifty way to start integrating Rails bits into existing applications or reuse existing Java web application code.</p> <p>I&#8217;ve tagged the release with an 0.9 version number. I believe the bits are ready for serious use, but could use some help pounding out a few more bugs before calling it 1.0. So <code>jruby -S gem install warbler</code> today, try it out, and bring plenty of feedback to the <a href="http://xircles.codehaus.org/lists/user@jruby.codehaus.org">JRuby user list</a>!</p> Thu, 08 May 2008 17:31:00 +0000 urn:uuid:dbf694f6-1c82-46b8-bffb-ee00a82f8390 Nick Sieger http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack jruby rails rack merb http://blog.nicksieger.com/articles/trackback/398