Nick Sieger: Warbler, A Little Birdie To Introduce Your Rails App To Java http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java en-us 40 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Stéphane Boulanger <p>@Nick: It´s in your mailbox!</p> <p>@Jonathan: I installed warbler into my regular ruby installation&#46; Works (now) without problems&#46;</p> Thu, 13 Sep 2007 07:51:11 +0000 urn:uuid:6877c409-b5b8-47b1-abfd-fd263b1c90a9 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-287 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Jonathan Bartlett <p>One other thing &#45;&#45; I don&#8217;t know if this is a configuration setting or something w/ Jruby itself&#46; When I use ActiveRecord&#45;jdbc to connect to a JNDI datasource, on every page access it gives me a warning that it is closing a connection for me and shaming me for not doing it myself (not to mention throwing a stacktrace)&#46; </p> <p>I&#8217;m deploying via JBoss, if that matters&#46;</p> <p>Here&#8217;s an example log message:</p> <pre> 18:29:42,339 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: <a href='mailto:org.jboss.resource.adapter.jdbc.WrappedConnection@add4cdjava.lang.Throwable' rel="nofollow">org.jboss.resource.adapter.jdbc.WrappedConnection@add4cdjava.lang.Throwable</a>: STACKTRACE at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290) ..several hundred more lines... </pre> Tue, 11 Sep 2007 23:40:05 +0000 urn:uuid:f0984376-949c-4e2f-8dc1-432fd18caaf3 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-286 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Jonathan Bartlett <p>One thing you should mention is that warbler should be installed from JRuby and not regular ruby&#46;</p> Tue, 11 Sep 2007 19:33:05 +0000 urn:uuid:a658980e-b076-4a66-9a10-10183be80170 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-285 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Joslyn <p>Update: Wasn&#8217;t pointing to my JRuby path to install the gem&#46; I feel like an idiot&#46;&#46; :)</p> <p>I&#8217;ll keep you posted on my results&#46; Our state agency is currently a Java shop and it would be great to present them the slight possibility of deploying rails apps on our WebSphere servers&#46; I&#8217;d much rather do development using Rails :)</p> Tue, 11 Sep 2007 18:22:51 +0000 urn:uuid:46bfec92-6629-4508-9c95-7801c5dfbe29 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-284 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Joslyn <p>I went ahead and completely reinstalled the latest ruby on my windows box and immediately tried installing warbler both remotely and from a local &#46;gem&#46; </p> <p>Both sill had the buffer error&#46; I was able to install other gems (such as rails)&#46; Any other information you need?</p> <p>WinXP Pro SP2 Ruby 1&#46;8&#46;5&#45;24</p> Tue, 11 Sep 2007 18:18:22 +0000 urn:uuid:1d4716be-0670-486d-8000-6eac787ef401 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-283 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Nick <p>@Stephane: please send it, I&#8217;d be happy to incorporate it&#46;</p> <p>@Joslyn: this is during install? Can you try downloading the gem from the <a href='http://rubyforge.org/frs/?group_id=2857&amp;release_id=14284' rel="nofollow">downloads page</a> and run gem install directly on the &#46;gem file? And is this with Ruby or JRuby?</p> Tue, 11 Sep 2007 17:09:28 +0000 urn:uuid:23a01228-9ae2-4575-b88b-7c1a060aff5e http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-282 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Joslyn <p>When I try installing the gem I get a buffer error: &#8220;ERROR: While executing gem &#46;&#46;&#46; (Zlib::BufError)&#8221;</p> <p>Anyone else getting this or have any suggestions&#46; I was excited to see this tool after running into no luck with any of the deployment tutorials&#46;</p> Tue, 11 Sep 2007 15:20:49 +0000 urn:uuid:a89ca32f-2fa3-4704-bdd4-26450e4a6129 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-281 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Stéphane Boulanger <p>Problem revised: It was not due to rake&#46; The command to unpack the gems did not succeed on my system&#46; But after calling <code>warble</code> several times, the specs of the gems were present in the working directory and warble presumed all gems were correctly unpacked and build the war file&#46;&#46;&#46; and making me think, my updating of rake had &#8220;solved&#8221; the problem&#46;</p> <p>@Nick: I fixed it my sources&#46; It uses <code>Gem::Installer</code> directly to unpack the gem&#46; Should I send you the snippet?</p> Tue, 11 Sep 2007 11:53:39 +0000 urn:uuid:7ec23e10-71b0-4c8f-bac6-e5aadb420bd4 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-280 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Nick <p>@Jeff: Interesting, I haven&#8217;t seen that issue yet&#46; Can you send more details to me in an email?</p> Mon, 10 Sep 2007 13:40:40 +0000 urn:uuid:1ec080f1-9a62-4252-bb76-8a356e08cf78 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-279 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Jeff Cooper <p>When I create a war file and try to run in tomcat, on startup i get a no class found for org/apache/commons/pool/PoolableObjectFactory for SEVERE: Error configuring application listener of class org&#46;jruby&#46;webapp&#46;RailsContextListener&#46; I looked in the WEB&#45;INF\lib directory and see commons&#45;pool&#45;1&#46;3&#46;jar&#46; Does anyone know how to solve this&#46; Thanks</p> <p>Jeff</p> Mon, 10 Sep 2007 10:56:00 +0000 urn:uuid:03bc3705-2213-446a-8c0f-e6b6af25664b http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-278 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Stéphane Boulanger <p>Nice job Nick!</p> <p> First, with the 0&#46;9 version, I received a <code>undefined method `exitstatus' for nil:NilClass</code> error&#46; I think this was due to my (old) <code>rake</code> version&#46; Upgrading warbler to 0&#46;9&#46;1 with <code>gem update warbler --include-dependencies</code> solved my problem! </p> <p>Stéphane</p> Fri, 07 Sep 2007 15:38:43 +0000 urn:uuid:4bb0b1e7-b12f-4f23-8974-8ec735821f46 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-277 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Nick <p>If you have custom gems (including <code>jruby-openssl</code> in this case), you&#8217;ll have to tell warbler about them&#46;</p> <p>Set up a <code>config/warble.rb file</code> with <code>warble config</code>, and edit it&#46; There&#8217;s a spot to add gems by name there&#46; As long as they&#8217;re present in the JRuby installation where you run warbler (or rake) from, they&#8217;ll get copied into your &#46;war file&#46;</p> Wed, 05 Sep 2007 17:49:30 +0000 urn:uuid:37605a52-8a8d-4666-8305-a26b53f46d13 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-276 "Warbler, A Little Birdie To Introduce Your Rails App To Java" by Jonathan Bartlett <p>Very nice! However, when when my app boots, it says &#8221; Failed to load Rails: Could not find RubyGem jruby&#45;openssl (>= 0&#46;0&#46;0)&#8221; </p> <p>I tried just a plain&#45;Jane test app, but it can&#8217;t find my database module &#8220;postgres&#8221;&#46;</p> <p>I think this is because these need extra JRuby&#45;specific gems&#46; How would I load them using warbler?</p> <p>I can get both of these running using plain JRuby very easily by just using JRuby&#8217;s gem installation function&#46; Do I need to copy folders from my local JRuby installation or is there some way to automate it with warbler?</p> Wed, 05 Sep 2007 16:04:33 +0000 urn:uuid:c487abdc-ba12-4ba9-86b9-91f9407f52a9 http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java#comment-275 Warbler, A Little Birdie To Introduce Your Rails App To Java <p>This week I was working on integrating the latest <a href="http://www.bloglines.com/blog/ThomasEEnebo?id=35">JRuby 1&#46;0&#46;1</a> and <a href="http://rubyforge.org/frs/shownotes.php?release_id=14048">Goldspike 1&#46;3</a> releases into our environment, when my frustration hit a fever pitch&#46;</p> <p>See, I had always thought that the &#46;war packaging side of Goldspike was a little clunky and un&#45;ruby&#45;like, but I didn&#8217;t see a clear path to fixing it&#46; I had heard little complaints about it here and there: the little configuration DSL didn&#8217;t give you enough control or wasn&#8217;t documented well enough; the fact that it downloads libraries from the internet during assembly (convenient, but not safe or reproducible for production deployments)&#46;</p> <p>Also, in my own opinion it took the wrong approach to packaging Rails in a &#46;war file&#46; It puts the Rails application directory structure into the root of the &#46;war file where any web server or Java application server might mistakenly serve up your code as static content&#46; The Java &#46;war file spec has this special directory called <code>WEB-INF</code> expressly for the purpose of hiding that stuff away, so why not use it?</p> <p>And then, suddenly Goldspike was packaging up my entire Rails application directory, &#46;svn directories and everything&#46; So I set out to fix this once and for all&#46;</p> <p>And so I present <a href="http://caldersphere.rubyforge.org/warbler/">Warbler</a>&#46; A little bird who chirpily steps up to the task of assembling your Rails application into a Java Web Archive (&#46;war)&#46; Here, get it:</p> <pre><code>gem install warbler </code></pre> <p>And then, in the top directory of your Rails application,</p> <pre><code>warble </code></pre> <p>Those two steps are all it takes to make a &#46;war file, including your application and recent versions of JRuby and Goldspike, that&#8217;s deployable to your <a href="https://glassfish.dev.java.net/">favorite Java application server</a>&#46;</p> <p>There are a number of points about Warbler worth mentioning&#46;</p> <h3>Does one thing, well</h3> <p>Warbler only packages, and doesn&#8217;t care about anything else, like how to dispatch servlet requests to Rails&#46; This will allow for more runtime servlet binding mechanisms to take advantage of Warbler in the future&#46;</p> <h3>Fast and lightweight</h3> <p>50% less code than the Goldspike packaging plugin, yet does the job quickly and efficiently&#46;</p> <h3>Sane defaults</h3> <p>Warbler only packages code that you need to run the application, omitting database migrations and tests&#46; If your application is self&#45;sufficient (no external dependencies), then the out&#45;of&#45;the&#45;box configuration will probably work for you&#46; Public HTML/images/javascript/stylesheets go in the root of the webapp, where Java webservers expect them to be&#46;</p> <h3>Documented, flexible configuration</h3> <p>Need to customize your configuration? Run <code>warble config</code> and edit <code>config/warble.rb</code>&#46; All the options are there, commented and documented&#46;</p> <p>Need to change out the bundled JRuby/Goldspike versions? <code>warble pluginize</code> makes a copy of Warbler in the <code>vendor/plugins</code> area of your application, allowing you to change the &#46;jar files in the <code>vendor/plugins/warbler-0.9/lib</code> directory&#46; Warbler then makes his nest in your project&#8217;s list of rake tasks (as <code>rake -T | grep war</code> shows)</p> <pre><code>rake war # Create trunk.war rake war:app # Copy all application files into the .war rake war:clean # Clean up the .war file and the staging area rake war:gems # Unpack all gems into WEB-INF/gems rake war:jar # Run the jar command to create the .war rake war:java_libs # Copy all java libraries into the .war rake war:public # Copy all public HTML files to the root of the .war rake war:webxml # Generate a web.xml file for the webapp </code></pre> <p>Warbler even omits himself in the &#46;war file produced when running in plugin mode, since you won&#8217;t need him at runtime&#46; It&#8217;s the little details that matter&#46;</p> <p>Give him a try and let me know if it makes your life deploying Rails applications to JRuby on Java appservers easier!</p> Tue, 04 Sep 2007 02:48:40 +0000 urn:uuid:a88e00d4-56b6-4b75-95e9-4e21e6b0387a Nick Sieger http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java jruby warbler rails http://blog.nicksieger.com/articles/trackback/274