rubyrakejrubywarwarbler

How to run rake tasks with warbler with -cp option


I have a jruby app that is being packaged into a war file. I am trying to run a rake task from my app. I know warbler gives a -S option to run rake tasks.

When I run the following command, everything runs fine:

java -jar /path/to/war/file/app.war -S rake namespace:start_task

But when I try to run the same command with a -cp option as follows. I get an error.

java -cp /path/to/war/file/app.war -S rake namespace:start_task

Error:

Unrecognized option: -S
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I am using a gem that has hard coded the -cp option to invoke execute the war file. I am wondering if there is a way to invoke a rake task in warbler using the -cp option.


Solution

  • java -jar does look for the main-class in the specified archive

    java -cp does only add a .jar to class-path

    ... it doesn't know what main-class to run you will need to set it manually

    e.g. java -cp app.war WarMain -S ...