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&#46; See <a href='http://blog' rel="nofollow">http://blog</a>&#46;nodeta&#46;fi/2008/05/22/living&#45;on&#45;the&#45;edge&#45;jruby&#45;merb&#45;glassfish/ for more information&#46;</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&#46; These are the kinds of bugs that obviously need to be fleshed out with wider use&#46; Is there nothing in the tomcat logs/catalina&#46;out file? If application initialization failed, there should definitely be something in it&#46;</p> <p>Can you try dropping in this debug build? I&#8217;ve added a few extra exception rescue&#45;and&#45;dump clauses that should hopefully make things more visible&#46; 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&#46;</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&#45;user list</a>&#46;</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&#46;9&#46;5 &#46; Additionally, there&#8217;s no log output anywhere &#45;&#45; I just get the rails 500 page&#46;</p> <p>I carefully revisited the new warble&#46;rb options as well as web&#46;xml&#46;erb &#45;&#45; to no avail&#46;</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&#46; Let&#8217;s work on it in IRC or on the mailing list&#46;</p> <p>@Osman: I don&#8217;t have a simple Rack example out there right now&#46; I&#8217;ll whip one up soon for you&#46;</p> <p>@ab5tract: 1) This is not tied to Glassfish (or the GF v3 gem) specifically&#46; It works off of the Java Servlet spec, so should work for any appserver&#46; 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&#46; If you look in the newly generated config/warble&#46;rb you might get a clue&#46; The example I&#8217;ll work up for Osman should help for you too&#46;</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&#46; No one responded though :(</p> <p>2 questions: 1) You do not mention Glassfish&#46; How do they tie together? Is jruby&#45;rack a replacement for goldspike? It seems strange to omit GF, since it looks very likely to become dominant in JRuby web app deployments&#46; 2) Why is Warbler said to be for &#8220;wrapping a Rails app&#8221; in a &#46;war? Why tie it to one framework? Is it secretly modular enough to &#46;war other web apps?</p> <p>I just want a way for to deploy my Waves app without bothering with the mess&#46; Thanks for bringing the community one step closer to achieving point&#45;and&#45;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&#46;</p> <p>I&#8217;m trying to run a simple rack application with jruby&#45;rack:</p> <p>class HelloWorld def call(env) [200, {&#8220;Content&#45;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&#46;xml and where to put hello&#46;rb file that contains above code&#46;</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&#46;3&#46;0 and 2&#46;4&#46;1 installed and couldn&#8217;t build rack (r159) until I deleted facets v2&#46;4&#46;1&#46; rubygems&#46;rb:140:in `activate&#8217;: can&#8217;t activate facets (= 2&#46;3&#46;0), already activated facets&#45;2&#46;4&#46;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&#45;rack:rails tag in there&#46; We&#8217;ll certainly use it&#46; </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&#46;&#46;&#46; rack doesn&#8217;t seem to be picking up requests to the context root (i&#46;e&#46;, &#8220;/&#8221; or &#8220;/myapp&#8221; if deployed to a relative context root) &#45;&#45; at least on oc4j&#46; 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&#46; At first I thought it was the filter&#45;mapping, so I changed from url&#45;pattern:/* to *&#46; That didn&#8217;t do it&#46; I also played around with reordering the filter in web&#46;xml &#45;&#45; above the listener and below the listener&#46;&#46;&#46; nope&#46;</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&#46; BTW, it does work on Jetty&#46;</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&#46;&#46; </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&#46; Try it yourself&#46;&#46;&#46; the HTTP head sig is different than the servlet error response&#46;</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&#46; Thank goodness for JavaOne! Wow&#46; I&#8217;m dreaming of little merb&#45;very&#45;flat or camping apps deployed under a java app container&#46;</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&#46; Looks good&#46;</p> <p>One thing&#46;&#46;&#46; 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&#46;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&#46; Anyway, just wondering if jruby&#45;rack provides a cleaner way of sending out this response&#46;</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&#45;Driven Development, I&#8217;m happy to announce the first public release of <a href="http://wiki.jruby.org/wiki/JRuby_Rack">JRuby&#45;Rack</a>! You can use it to run Rails, Merb, or any Rack&#45;compatible application inside a Java application server&#46;</p> <p>Also released today is <a href="http://caldersphere.rubyforge.org/warbler/">Warbler 0&#46;9&#46;9</a>, which has been updated to bundle JRuby&#45;Rack&#46;</p> <p>In addition to providing as seamless a connection as possible between the servlet environment and Rack, JRuby&#45;Rack (along with Warbler) is also bridging the gap between Ruby and Java web development&#46; 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&#46; Request attributes can override Rack variables such as <code>PATH_INFO</code>, <code>QUERY_STRING</code> etc&#46;</li> <li>Configures Rails deployment options such as page caching directories and session handling automatically and optimally for the servlet environment&#46;</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&#46; 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&#46; I think this provides a nifty way to start integrating Rails bits into existing applications or reuse existing Java web application code&#46;</p> <p>I&#8217;ve tagged the release with an 0&#46;9 version number&#46; I believe the bits are ready for serious use, but could use some help pounding out a few more bugs before calling it 1&#46;0&#46; 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