Java program can not take any argument

Dear All,

I am tryin to deploy a java *.jar based software on OOD with “java -jar code.jar -port 64444”, but it seems that the OOD only executes the command with “java -jar code.jar”. May I ask if there is a way to solve this?

Thank you in advance,

Dawei

Dawei,

Are you trying to launch the jar using Job Composer or Batch Connect?

Hi,

Thank you for your help, I am using batch connect.

Best,

Dawei

There is nothing in OnDemand that would reject arguments within your template/script.sh.erb. Would you mind sharing your script with us so that we can help debug it?

#
# Load modules
#

<%- unless context.modules.blank? -%>

# Purge the module environment to avoid conflicts

module purge

# Load additional modules

module load <%= context.modules %>

# List loaded modules

module list

<%- end -%>

#
# Start H2O-AI Server
#

# Set working directory to home directory
cd "${HOME}"

java -jar /opt/apps/h2o-3.26.0.11/h2o.jar \ -port \ "${app_port}"

It’s the backslashes without newlines in bash that’s giving you the problem.

#either do multi line with \ seperated
java -jar /opt/apps/h2o-3.26.0.11/h2o.jar \
 -port \
 "${app_port}"

# or single line without any \s
java -jar /opt/apps/h2o-3.26.0.11/h2o.jar -port "${app_port}"

In addition, what sets the environment variable app_port?

Thank you for your help.

we tried the single line cmd “java -jar /opt/apps/h2o-3.26.0.11/h2o.jar -port “${app_port}””, which didn’t work, the “-port” can not be imported in OOD.

we set up the enviornment in “before.sh.erb”, which is printed in both “before” and “after” scripts and they are consistent.
“export app_port=(find_port {host})”

OOD templates these shell scripts then submits the main one to the scheduler. At this point, it’s in the scheduler hands (and runtime). Then the environment becomes just Linux/bash. This is where I think the issue is.

If you’re still having problems, to help diagnose the issue, let’s remove OOD from the equation. I would suggest navigating to a directory that this batch job created, looking at the resulting shell scripts, modifying them and resubmitting them by hand (with whatever debug statements you need) to see what’s really going on.

# here's an example one that I have
/users/PZS0714/johrstrom/ondemand/data/sys/dashboard/batch_connect/sys/bc_osc_jupyter/output/feb7fbd3-3792-4f3b-be95-6e8de9502f9f

# here's how that directory may differ
$YOUR_HOME/ondemand/data/sys/dashboard/batch_connect/{sys,dev,usr}/$APP_NAME/output/$SOME_UUID

In this directory you’ll see a job_script_content.sh This was the shell script that was submitted to your scheduler. Look at it to see what the result was and if it’s what you’d expect.

Now you can re-submit this script in this working directory. In moab/torque parlance it’s qsub -d $(pwd) job_script_content.sh. With this, you can play around with the formatting

Hope that helps! Let us know what you find.

@superdavidxp did you find what the issue was?

Hi Jeff,

Thank you so much for your reply, I have solve the problem, which I should use get instead of post for the web content.

Best,

Dawei