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. Works (now) without problems.</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 &#8211; I don&#8217;t know if this is a configuration setting or something w/ Jruby itself. When I use ActiveRecord-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). </p> <p>I&#8217;m deploying via JBoss, if that matters.</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.</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. I feel like an idiot.. :)</p> <p>I&#8217;ll keep you posted on my results. 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. 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 .gem. </p> <p>Both sill had the buffer error. I was able to install other gems (such as rails). Any other information you need?</p> <p>WinXP Pro SP2 Ruby 1.8.5-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.</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 .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 &#8230; (Zlib::BufError)&#8221;</p> <p>Anyone else getting this or have any suggestions. I was excited to see this tool after running into no luck with any of the deployment tutorials.</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. The command to unpack the gems did not succeed on my system. 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&#8230; and making me think, my updating of rake had &#8220;solved&#8221; the problem.</p> <p>@Nick: I fixed it my sources. It uses <code>Gem::Installer</code> directly to unpack the gem. 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. 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.jruby.webapp.RailsContextListener. I looked in the WEB-INF\lib directory and see commons-pool-1.3.jar. Does anyone know how to solve this. 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.9 version, I received a <code>undefined method `exitstatus' for nil:NilClass</code> error. I think this was due to my (old) <code>rake</code> version. Upgrading warbler to 0.9.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.</p> <p>Set up a <code>config/warble.rb file</code> with <code>warble config</code>, and edit it. There&#8217;s a spot to add gems by name there. 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 .war file.</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-openssl (>= 0.0.0)&#8221; </p> <p>I tried just a plain-Jane test app, but it can&#8217;t find my database module &#8220;postgres&#8221;.</p> <p>I think this is because these need extra JRuby-specific gems. 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. 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.0.1</a> and <a href="http://rubyforge.org/frs/shownotes.php?release_id=14048">Goldspike 1.3</a> releases into our environment, when my frustration hit a fever pitch.</p> <p>See, I had always thought that the .war packaging side of Goldspike was a little clunky and un-ruby-like, but I didn&#8217;t see a clear path to fixing it. 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).</p> <p>Also, in my own opinion it took the wrong approach to packaging Rails in a .war file. It puts the Rails application directory structure into the root of the .war file where any web server or Java application server might mistakenly serve up your code as static content. The Java .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, .svn directories and everything. So I set out to fix this once and for all.</p> <p>And so I present <a href="http://caldersphere.rubyforge.org/warbler/">Warbler</a>. A little bird who chirpily steps up to the task of assembling your Rails application into a Java Web Archive (.war). 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 .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>.</p> <p>There are a number of points about Warbler worth mentioning.</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. This will allow for more runtime servlet binding mechanisms to take advantage of Warbler in the future.</p> <h3>Fast and lightweight</h3> <p>50% less code than the Goldspike packaging plugin, yet does the job quickly and efficiently.</p> <h3>Sane defaults</h3> <p>Warbler only packages code that you need to run the application, omitting database migrations and tests. If your application is self-sufficient (no external dependencies), then the out-of-the-box configuration will probably work for you. Public HTML/images/javascript/stylesheets go in the root of the webapp, where Java webservers expect them to be.</p> <h3>Documented, flexible configuration</h3> <p>Need to customize your configuration? Run <code>warble config</code> and edit <code>config/warble.rb</code>. All the options are there, commented and documented.</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 .jar files in the <code>vendor/plugins/warbler-0.9/lib</code> directory. 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 .war file produced when running in plugin mode, since you won&#8217;t need him at runtime. It&#8217;s the little details that matter.</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