Forum: JRuby How to run script/runner (Rails) without jruby installation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F1b6c141ae2c2efe756cf7988f254be0?d=identicon&s=25 Harri Kauhanen (Guest)
on 2009-03-04 07:18
(Received via mailing list)
Hi,

I deliver a Rails project to my client as a single WAR-package. It
works great, the client does not need to install anything but the JEE
servers they already have.

Now, I need to set up a cron task that can be run using with the
following script:

   export RAILS_ENV=production
   export CLASSPATH=./lib/ojdbc14.jar
   export GEM_PATH=./gems/
   jruby -S script/runner "Nightly.run"

It works fine, but requires the client to install jruby. Much nicer
solution would use the jruby bundled within the war package. I could
not get it working, because I will get:

   Rails requires RubyGems >= . Please install RubyGems and try again:
http://rubygems.rubyforge.org

The script I use:

   export RAILS_ENV=production
   export CLASSPATH=./lib/ojdbc14.jar:./lib/jruby-complete-1.1.4.jar
   export GEM_PATH=./gems/
   java org.jruby.Main -w -S script/runner "Nightly.run"

I also tried:

   java -jar /lib/jruby-complete-1.1.4.jar -S script/runner
"Nightly.run"

But the same error occurs (and I cannot use environment variables at
all with the -jar option)

I'm sure there's the solution, but cannot figure out what is is. Any
ideas?

-harri.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2009-03-04 14:23
(Received via mailing list)
On Wed, Mar 4, 2009 at 12:18 AM, Harri Kauhanen
<harri.kauhanen@futurice.com> wrote:
>  export CLASSPATH=./lib/ojdbc14.jar
> The script I use:
> But the same error occurs (and I cannot use environment variables at all
> with the -jar option)
>
> I'm sure there's the solution, but cannot figure out what is is. Any ideas?

If you can, upgrade to jruby-complete-1.1.6.jar. It will detect
rubygems out of the complete jar automatically. Otherwise, your runner
scripts look pretty reasonable to me.

/Nick

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F1b6c141ae2c2efe756cf7988f254be0?d=identicon&s=25 Harri Kauhanen (Guest)
on 2009-03-04 15:15
(Received via mailing list)
If I use jruby-complete-1.1.6.jar with...

      java org.jruby.Main -w -S script/runner "Nightly.run"

...I will get something like this (did not happen with 1.1.4)...

     :1: ./script/runner:1: unknown regexp options - rr (SyntaxError)

...but if I use...

    java -jar /lib/jruby-complete-1.1.4.jar -S script/runner
"Nightly.run"

...it seem to load Rails gems, great! I will encounter another
problem, however:

    The driver encountered an error: cannot load Java class
oracle.jdbc.OracleDriver

So it does not find the jar I defined in the CLASSPATH.

More ideas?

-harri.



On Mar 4, 2009, at 15:22 , Nick Sieger wrote:

>> Now, I need to set up a cron task that can be run using with the
>> would use the jruby bundled within the war package. I could not get
>>  export GEM_PATH=./gems/
>>
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
6fb2fc2840fa0d2f6937a412422346c0?d=identicon&s=25 Chris Andrews (Guest)
on 2009-03-04 18:23
(Received via mailing list)
On Wed, Mar 4, 2009 at 6:18 AM, Harri Kauhanen
<harri.kauhanen@futurice.com> wrote:
>  export CLASSPATH=./lib/ojdbc14.jar
>  export GEM_PATH=./gems/
>  jruby -S script/runner "Nightly.run"

It might be a bit heavyweight for your needs, but in my project I've
used the Quartz Scheduler to do this entirely within the container.

  http://www.opensymphony.com/quartz/

I used the quartz-jruby-plugin from here to hook it into Rails:
  http://github.com/macarthy/mirror-quartz-jruby-plu...

You specify cron-like schedules and commands to be run in your
web.xml.erb, and it all gets bundled up correctly by Warbler.


Chris.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2009-03-04 18:40
(Received via mailing list)
On Wed, Mar 4, 2009 at 8:15 AM, Harri Kauhanen
<harri.kauhanen@futurice.com> wrote:
> If I use jruby-complete-1.1.6.jar with...
>
>     java org.jruby.Main -w -S script/runner "Nightly.run"
>
> ...I will get something like this (did not happen with 1.1.4)...
>
>    :1: ./script/runner:1: unknown regexp options - rr (SyntaxError)

An odd error. Just for kicks can you try it without -S? I.e., `java
org.jruby.Main -w script/runner "Nightly.run"'.

> So it does not find the jar I defined in the CLASSPATH.
Yes. CLASSPATH is unfortunately ignored when using the -jar form. You
can add the driver to the load path like so:

java -jar /lib/jruby-complete-1.1.4.jar -r./lib/ojdbc14.jar
script/runner "Nightly.run"

/Nick

>> <harri.kauhanen@futurice.com> wrote:
>>> script:
>>>
>>> I also tried:
>> rubygems out of the complete jar automatically. Otherwise, your runner
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F7e175b37a4c69709ef75c28792f2b32?d=identicon&s=25 Ikai Lan (Guest)
on 2009-03-04 19:55
(Received via mailing list)
Chris, I don't think this code will work with a new version of Jruby. I
do
remember some chatter a while back about some work that was being put
into
updating Jruby-quartz.

Here's the Github repo of Christian Müller's Quartz Scheduler, updated to
work with recent versions of JRuby:

http://github.com/muellerc/quartz_scheduler/tree/master

Ikai

On 3/4/09 9:22 AM, "Chris Andrews" <chris@nodnol.org> wrote:

>>
> I used the quartz-jruby-plugin from here to hook it into Rails:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
6fb2fc2840fa0d2f6937a412422346c0?d=identicon&s=25 Chris Andrews (Guest)
on 2009-03-04 21:02
(Received via mailing list)
On Wed, Mar 4, 2009 at 6:54 PM, Ikai Lan <ilan@linkedin.com> wrote:
> Chris, I don't think this code will work with a new version of Jruby. I do
> remember some chatter a while back about some work that was being put into
> updating Jruby-quartz.

Recent as in 1.1.6, or more recent than that? I definitely have
something based on that code working on 1.1.6 now, though I think I
made some minor local modifications - would have to check.

> Here's the Github repo of Christian Müller's Quartz Scheduler, updated to
> work with recent versions of JRuby:
>
> http://github.com/muellerc/quartz_scheduler/tree/master

Shall take a look, thanks! At some point I do want to get the
clustered scheduler mode to work, so I'll have to look at this again.


Chris.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F7e175b37a4c69709ef75c28792f2b32?d=identicon&s=25 Ikai Lan (Guest)
on 2009-03-04 22:35
(Received via mailing list)
I've never had this working on anything more recently than 1.0.1. I
think
the way it uses getRuby() changed and broke the Java part of
jruby_quartz.

Ikai


On 3/4/09 12:02 PM, "Chris Andrews" <chris@nodnol.org> wrote:

>> work with recent versions of JRuby:
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.