[jruby] Scriptlet not looked up in Jar file, but always in file system!!!

christian m.kristian at web.de
Fri Jan 8 01:12:26 JST 2016


yes, that is what I expected that the resolution is relative to the working
directory. either use the PathType.CLASSPATH or use the
IsolatedScriptingContainer which sets the current working directory into
the jar.

- christian


On Thu, Jan 7, 2016 at 4:40 PM, <changepoint_advi.fischer at extaccount.com>
wrote:

> (jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit
> Server VM 1.7.0_79-b15 +jit [Windows 7-amd64])
>
> I have my Java classes and my Ruby sources all in a Jar file (i.e. I would
> like to deliver everythin in a jar), and I call my scriptlet with
>
>  ScriptingContainer container = new
> ScriptingContainer(LocalContextScope.CONCURRENT);
>
>  container.runScriptlet(org.jruby.embed.PathType.RELATIVE,"rubyapp/myscriptlet.rb");
>
> However, myscriptlet.rb is always loaded from the file system, not from
> the Jar file. I can verify this by copying my Jar file to a different
> directory.  Running the application from the original works fine, but
> running it from the copied location, I get an exception:
>
>    java.io.FileNotFoundException: C:\tmp\ctest\rubyapp\myscriptlet.rb
>
> From the path printed in the error message, I can see that the scriptlet
> is searched relative to the working directory (C:\tmp\ctest).
>
> My scriptlet is included in the Jar like this:
>
>   jar myapp.jar .... foo\x.class foo\y.class rubyapp\myscriptlet.rb
>
> I tried to run my application in two different ways (but both having the
> same problem):
>
> (1) Using 2 Jar files (one for JRuby itself, one for my application), and
> -cp
>
> java -cp jruby-complete-1.7.23.jar;myapp.jar MainClass
>
> (2) Combining the JRuby jar file AND my own myapp.jar file into a single
> Jar file, and running it as
>
>    java -jar combined.jar
>
> What am I doing wrong?
>
> If you are not the addressee, please inform us immediately that you have
> received this e-mail by mistake, and delete it. We thank you for your
> support.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20160107/0819dafe/attachment.html>


More information about the JRuby mailing list