Executable jar with rails application

so I tried to take a jruby-complete-1.6.0.RC2.jar and just add a rails
application in it. the ‘app’, ‘config’, ‘script’ etc directories I
just put into the root of the jar file as well the rubygems inside a
gems and specification directory.

then I added a java class:
public class Rails
{
public static void main( String[] args )
{
ScriptingContainer container = new ScriptingContainer();
container.getProvider().getRubyInstanceConfig()
.setJRubyHome(Thread.currentThread()
.getContextClassLoader()
.getResource(“META-INF/jruby.home”)
.toString()
.replaceFirst("^jar:", “”));
System.out.println(“jrubyhome: " + container.getHomeDirectory());
String rails = Thread.currentThread()
.getContextClassLoader()
.getResource(“script/rails”)
.toString()
.replaceFirst(”^jar:", “”);
String script = “p require ‘bigdecimal/util’\n”;
script += “p require ‘benchmark’\n”;
script += “p require ‘cgi’\n”;
script += “p require ‘forwardable’\n”;
script += “p require ‘racc/parser’\n”;
script += “p require ‘jruby/openssl/stub’\n”;
script += “ARGV.replace [‘server’];load(’” + rails + “’)\n”;
System.out.println(script);
container.runScriptlet(script);
}
}

with this a freshly scaffolded rails application works.

the odd thing is that I need to require some files before running the
rails script otherwise the startup stops with “no such file to load –
jruby/openssl/stub” or so.

these requires are no solution in the long run.

anything I need to do differently to configure the ScriptingContainer ?

thanx + regards Kristian

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs