warbler
Warbler chirpily constructs .war files of your Ruby applications.
My rails project is deployed to tomcat with the help of warbler, but I need to be able to run rake tasks on that server.
Source: (StackOverflow)
I've been having a tough time getting jRuby on Rails 3 deployed on Tomcat 6. I got it to work exactly once.
I modified my database.yaml and Gemfile to check for jRuby, something like this:
if defined?(JRUBY_VERSION)
gem 'jdbc-mysql'
#gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
#gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'
else
gem 'mysql'
gem "mongrel"
gem 'ruby-debug'
end
Some environment settings:
$ rvm -v
rvm 1.0.14
$ jruby -v
jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]
When I run jruby -S bundle install
everything goes smoothly.
It's when I try to do something like rake db:migrate
, jruby -S rake db:migrate
or warble
that I get 50 DEPRECATION WARNINGs and an eventual stackoverflow.
I solved this issue by deleting the warbler plugin, it did not like the line Warbler::Task.new
Next, I ran warble config
to give me a config/warbler.rb file.
And finally, warble
to create my .war file. So far so good.
Now I move the .war file to my Tomcat webapps. Everything works fine except for an error:
Oct 10, 2010 1:34:46 AM org.apache.catalina.core.ApplicationContext log
SEVERE: Application Error
org.jruby.rack.RackInitializationException:
http://github.com/plataformatec/devise.git (at master) is not checked out.
Please run 'bundle install'
I solved this problem once and only once by going into my webapps/myapp/WEB-INF and running jruby -S bundle install
It no longer works and I have no idea what is going on.
Source: (StackOverflow)
I am trying to create a simple executable war file using sinatra and warble. I have a simple lib/app.rb file with:
require 'rubygems'
require 'sinatra'
class Hiwar < Sinatra::Application
get '/' do
body "Hi!"
end
end
a config.ru file with:
require 'rubygems'
require 'lib/app'
run Hiwar.new
and a config/warble.rb file with:
Warbler::Config.new do |config|
config.dirs = %w(config lib)
config.gems += ["sinatra","rack","rack-protection","tilt","jruby-openssl"]
end
When I execute:
$ warble executable war
I obtain:
warble aborted!
Zip end of central directory signature not found
Tasks: TOP => war:files
(See full trace by running task with --trace)
I have seen that if I remove the gem "jruby-openssl" from the list, it does not complain and creates the war file, but when I execute it, it raises a 500 error:
undefined method `ssl?' for class `Sinatra::Request'
Is there a simpler way to generate an executable jar with sinatra?
Source: (StackOverflow)
I'm trying to deploy a Rails app as a WAR using Warbler. I have it running in Tomcat 6 and it seems to be running fine. However, all of my PUT
and DELETE
requests are getting rejected with a 403 (Forbidden)
.
From what I've been able to gather, the default Tomcat install on Debian/Ubuntu has these methods disabled via:
<init-param>
<param-name>readonly</param-name>
<param-value>true</param-value>
</init-param>
I've tried setting this to false
in my /etc/tomcat6/web.xml
but no dice. I wonder if I have to do something similar to the jruby-rack
servlet container packaged by Warbler in my WAR? If so, how would I go about this?
If not, why would Tomcat be rejecting all of the PUT
s and DELETE
s being sent to my Rails app?
Source: (StackOverflow)
My project requires both Rails and Java for special scaling ability.
We firstly started a pure JRuby on Rails project, and deploy it to Tomcat. The problem is our Tomcat server has a very limited resource with only 20-30 threads. It means that our web app can only concurrently serve 20-30 users at a time.
We plan to improve the throughput by converting some heavy synchronous code to evented-code by using EventMachine. With evented-code a single thread can do more work instead of waiting for a long-time job to finish.
But to use EventMachine, the web server must be event-based, while Tomcat is not the case.
It seems there is no hybrid multi-threaded and evented solution in JRuby/Tomcat, so we decide to combine the asynchronous support in Servlet 3.0 with our current Rails app. Some parts of the code will be written in Java with Servlet library. It sounds crazy, but we think it's the most suitable for us.
Is there anyway I can do that with JRuby Rails, Warbler and Java Servlet 3.0 ?
Thanks for all your interest. Any suggestion is very appreciated.
Source: (StackOverflow)
When packaging the application using warbler, the symbolic links are lost and the actual contents the symlink points to are packaged as part of the WAR.
In my case, I have a symlink from public/images/upload to /var/myproject/upload. After I deploy the war in tomcat, in the exploded folder public/images/upload has all the contents of /var/myproject/upload copied to it instead of linking to the folder.
UPDATE: My questions is "will warbler retain the symbolic links inside the project when deployed as a war?"
Environment Info:
jruby 1.6.2 (ruby-1.8.7-p330) | warbler 1.3.1 | Cent OS 5.5 | Java SE "1.6.0_26"
Source: (StackOverflow)
I'm deploying a JRuby/Rails app packed up into "abc.war", and it is deployed with a Java app packed up into "def.war" in the same Tomcat instance.
I have a resource in my Rails application called "Blogs", with the following entry in routes.rb
resources :blogs
With this entry in routes.rb, I have helpers such as blogs_path() so I can use statements such as:
<%= link_to "Blogs", blogs_path %>
in my application view file, and hitting the generated link displays a list of blogs.
When this application runs standalone with the Webrick web server (JRuby 1.6.4, configured with Ruby 1.9, and Rails 3.0.10), it works fine, in that http://localhost:3000/blogs gets me a list of blogs when I hit that link). When I deploy the app to another base server URL such as, say, "http://funky-freddy-101.heroku.com", then I don't have to change the code with "blogs_path", because Rails automagically figures out the base URL and blogs_path() code takes that into account when building the actual URL generated by "blogs_path".
When deploying the app to JRuby/Tomcat in the file "abc.war", the base URL changes from http://localhost:3000" to "http://localhost:8081/abc". So typing "http://localhost:8081/abc/blogs" in the browser will give me a list of blogs, and "http://localhost:8081/blogs" gives me a 404 error. However, the problem is that although the base URL for the application includes the suffix of the WAR file name (i.e. "abc") Rails has not picked up on that and therefore still generates "http://localhost:8081/blogs" as the URL when blogs_path() is called. When I click on the link, it gives me the standard Tomcat 404 page.
Is there any simple way to get Rails to get the base URL suffixed with the reference "abc", the name of the WAR file, and generate URLs appropriately in a JRuby/Tomcat deployment? And because this application is running alongside def.war, I cannot make it the root app.
Source: (StackOverflow)
I am using Rvm and have install jruby-1.6.4 (with ruby 1.9.2)
i use warbler to create the war file and deploy it over tomcat-6.0.4
the problem is while i run the application the tomcat logs shows ruby version used as 1.8.7
I checked the version of ruby thru rvm list and it shows the right version (1.8.7)
When i downgrade teh jruby to use 1.8.7 (by using JRUBY_OPTS=--1.8.7 the application works like charm
any idea on how to ensure that ruby version 1.9.2 is used by tomcat
Vivek
Source: (StackOverflow)
So, I'm attempting to deploy my JRuby on Rails app to Tomcat 7. Everything works fine.
Until I tried using Tomcat's Parallel Deployment feature, which requires that the context/war name be of the form name##VERSION.war
.
JRuby chokes on this the first time I try to require a file with a ##
in the path, with the following stacktrace:
org.jruby.rack.RackInitializationException: no !/ in spec
from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack.rb:7:in `(root)'
from org/jruby/RubyKernel.java:1038:in `require'
from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack.rb:28:in `boot!'
from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:10:in `Rack'
from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:8:in `(root)'
from org/jruby/RubyKernel.java:1063:in `load'
from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:1:in `(root)'
at org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:206)
at org.jruby.rack.DefaultRackApplicationFactory.newErrorApplication(DefaultRackApplicationFactory.java:102)
at org.jruby.rack.DefaultRackApplicationFactory.getErrorApplication(DefaultRackApplicationFactory.java:66)
at org.jruby.rack.SharedRackApplicationFactory$1.call(SharedRackApplicationFactory.java:33)
at org.jruby.rack.AbstractRackDispatcher.process(AbstractRackDispatcher.java:30)
at org.jruby.rack.AbstractFilter.doFilter(AbstractFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
As the stack trace indicates, it seems to be blowing up on the require. Can JRuby just not handle paths of this form? Is there any way I can get around this issue, or is it a fundamental conflict between JRuby and Tomcat's naming convention?
UPDATE
I attached a debugger to Tomcat, and the problem goes all the way down to the way java.net.URL parses URL strings:
new URL("jar:file:/opt/apache-tomcat-7.0.23/webapps/my-app##001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack-1.3.6/rack.rb")
This blows up with a MalformedURLException. But:
new URL("jar:file:/opt/apache-tomcat-7.0.23/webapps/my-app/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack-1.3.6/rack.rb")
This is identical except for the ##001
in the application name, and it works fine.
These are invoked on line 1145 of org.jruby.runtime.load.LoadService in JRuby, by the way.
So what are the ramifications of this? Well, for one thing, it looks like Tomcat may have made a poorly considered choice in the characters it uses to indicate names, if it gives trouble to URL parsing. I'm not sure if JRuby can work around this easily.
Thoughts, anyone?
FURTHER UPDATE
You can make it work if you URL escape the hashes. ## becomes %23%23. This will need to be patched in JRuby itself, however, I think.
Source: (StackOverflow)
Is there a recommended workaround for warbler not supporting the path options in a Gemfile?
Is there a fundamental reason why path is not supported (and I couldn't just implement it)?
Source: (StackOverflow)
How can I add META-INF/context.xml into the war? I didn't find any config entry in config/warble.rb.
Source: (StackOverflow)
I'm doing some work on a RoR application that gets deployed as a war file using warbler. Prior to my involvement, the few images in the app were in the asset pipeline, but my role is to introduce slippy maps and homegrown map tiles.
Because the tiles take up a lot of space, and because they won't change anywhere near as often as the app, the idea was to simply serve them from public/images/tiles
. The war file for the rest of the app would be deployed, then the tiles would be untarred into the proper directory.
This works fine in development mode, but the warbler deployment uses a context path and the tiles get 404ed because they're found at /contextpath/images , not /images
I haven't worked in a jruby environment before and the rest of the team just so happens to be out on vacation this week (ha!). Nick Sieger's recommendation about using config.action_controller.asset_host
at Warbler: Where are my images wrecks the images and css that do work via assets, so I'd be grateful for any other suggestions that allow assets and public to coexist.
Source: (StackOverflow)
I've created a simple 'hello' type JRuby application and use Warbler to WAR up and then deploy to JBoss. However, I get the following error when using the application:
ActiveRecord::JDBCError (The driver encountered an unknown error: java.sql.SQLException: path to '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo-exp.war/WEB-INF/db/production.sqlite3': '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo-exp.war/WEB-INF/db' does not exist):
Sure enough when I dig into the demo.war file the db directory is missing from WEB-INF directory. The db directory exists in the app directory though along with test, development and production database files.
Any ideas?
Source: (StackOverflow)
I think I may have found a bug in Warbler, but I wanted to post this here as a question in case there's something I'm doing wrong. In a nutshell, any attempt to take a jruby app that requires the 'bson' gem an package it into a .jar file with warbler fails. Here's the error that I get, every time:
LoadError: no such file to load -- jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/../ext/java/jar/mongo-2.6.5 ...
Here's a very simple set of steps to reproduce the problem on OS X or Linux:
Make a 'wartest' dir and cd into it
Using bundler, make a new jruby-1.6.7.2 gemset called 'wartest'. Then do 'rvm use jruby-1.6.7.2@wartest'
Install warbler and bundler:
jruby --1.9 -S gem install warbler
jruby --1.9 -S gem install bundler
And just to confirm that it works:
which warble
#=> /Users/jstokes/.rvm/gems/jruby-1.6.7.2@wartest/bin/warble
Now create the following, two-line Gemfile:
#Gemfile
source 'http://rubygems.org'
gem 'bson'
Now 'bundle install'
Now make a bin directory and create the file bin/main.rb. Then paste in the following:
#bin/main.rb
require 'bson'
puts 'It worked!'
At this point, we're ready to create the jar file. So do
jruby --1.9 -S warble jar
#=> rm -f wartest.jar
#=> Creating wartest.jar
Now for the moment of truth:
java -jar wartest.jar
#=> It worked!
So what's the problem? The problem is that if you change to another gemset, or use system ruby, it's going to blow up. Observe:
rvm use system
#=> Now using system ruby.
java -jar wartest.jar
LoadError: no such file to load -- jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/../ext/java/jar/mongo-2.6.5
require at org/jruby/RubyKernel.java:1027
require at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at jar:file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/gems/bson-1.8.0-java/lib/bson.rb:53
require at org/jruby/RubyKernel.java:1027
(root) at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
require at jar:file:/var/folders/xr/nmvhn6x566v6xkw9l7pgpkj40000gn/T/jruby5567740032767770706extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:60
load at org/jruby/RubyKernel.java:1046
(root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/wartest/bin/main.rb:1
require at org/jruby/RubyKernel.java:1027
(root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/META-INF/main.rb:1
(root) at file:/Users/jstokes/Local/Repositories/wartest/wartest.jar!/META-INF/main.rb:1
If I go back and jar xf wartest.jar, and go into the gems/bson-1.8.0-java dir, the mongo-2.6.5.jar file exists and is in the right place. But for some crazy reason, it just can't be found. This happens every time, on both Ubuntu and OS X. If someone knows what I'm doing wrong, please tell me. Otherwise I'll file a bug report.
And if I file a bug report, whose bug is this? I presume that it's a warbler bug, but I'm not seeing it with any other gem besides bson (and mongo, which depends on bson).
Source: (StackOverflow)
FFI understands :size_t
when running rails through jRuby, but not after using Warbler to create a .war file and running that using java -jar my_project.war
or Tomcat.
Linux | Windows
-----------------------------+-------------
java -jar works | doesn't work
tomcat works | doesn't work
rails s (using jruby) works | works
Linux and Windows use the same war file in the comparison.
Here is the top of a backtrace from running java -jar
on Windows. (I've edited the beginnings of the file paths in the backtrace).
--- Backtrace
TypeError: unable to resolve type 'size_t'
find_type at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:55
type_size at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:147
SQLAnywhere at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:13
(root) at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:5
require at org/jruby/RubyKernel.java:1027
When I look at the files in the backtrace, they list various c types, but not size_t
.
It seems to me that there are 2 FFIs available to jRuby.
The big difference between the 2, seems to be that only the former understands :size_t
.
My question is: Are there 2 different FFIs?
If so: how do I make sure that my gem loads the correct ffi?
If not: what am I doing wrong?
PS: I'm the author of the sqlanywhere-ffi gem, so if the problem is I'm depending on the wrong thing, I can change it. Currently it has ffi as a depenendency in the gemspec, the gemfile and it requires 'ffi'
in the main entry point.
Source: (StackOverflow)