0

I've created an openshift app called "java" with the following cartridges:

  • Tomcat 6 (JBoss EWS 1.0)
  • Cron 1.4

I have a pulled the app into my local directory and added directory "lib" and my executable "testapp.jar".

..\java\src\main\webapp\lib\testapp.jar

I added a 'minutely' cron job file called "java"

..\java.openshift\cron\minutely\java

I successfully committed the directory and the cron file. But the cron job keeps failing to find and execute the testapp.jar.

I tried the following two scripts:

java -jar $OPENSHIFT_HOMEDIR/src/main/lib/testapp.jar

java -jar $OPENSHIFT_REPO_DIR/lib/testapp.jar

Neither works and I keep getting a message that testapp.jar can't be found.

So clearly, my reference is incorrect. Apparently, I should be using OPENSHIFT_DATA_DIR as it's the only persistent directory.

I would like to ask for help with the cron script as I am not having much luck referencing (executing) my testapp.jar.

Could anyone please give me an example of how to correctly reference reference the testapp.jar using the OPENSHIFT_DATA_DIR environment variable?

1 Answer 1

1

I ended up using the $OPENSHIFT_REPO_DIR environment variable instead which references the root directory of the application on local machine. It is the directory including .git and .openshift sub-directories.

I created the following minute cron file:

..\java.openshift\cron\minutely\java

cd $OPENSHIFT_REPO_DIR java -jar
$OPENSHIFT_REPO_DIR/src/main/webapp/lib/testapp.jar

Now I am able to run a jar file and schedule an execution of the jar file.

One additional note. Make sure to compile the code with jre 1.7 as I was getting an exception:

Exception in thread "main" java.lang.UnsupportedClassVersionError: App : Unsupported major.minor version 52.0 when I compiler the code using jre 1.8.

Java OpenJDK 1.7 is used by OpenShift.

source: OpenShift uses JBoss EWS 1.0 and 2.0 for Tomcat 6 and 7 respectively. EWS is a hardened and Red Hat supported version of Apache Tomcat. Both versions use Java OpenJDK 1.7.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.