1

the following shell script reads a file but returns an error when executing esscs.sh: Error: Could not find or load main class a

cd /u01/oracle/essbase/products/Essbase/EssbaseServer/bin/cli/
while read application; do
        if [[ $application = "" || $application = "#"* ]]
        then
                continue
        else
                ./esscs.sh login -user usr -password xxx -essbaseurl https://bla/essbase
                ./esscs.sh lcmexport -application $application
        fi
done < /tmp/exportLCM_applications.txt

The following shell script works just fine:

cd /u01/oracle/essbase/products/Essbase/EssbaseServer/bin/cli/
./esscs.sh login -user usr -password xxx -essbaseurl https://bla/essbase
./esscs.sh lcmexport -application hardcodedapp

This is the content of esscs.sh which an Oracle command line utility for Essbase (cli):

#!/bin/sh

export ERR_MSG_JAVA_REQUIRED="Install JDK8 and set JAVA_HOME variable to JDK8 installed location"

if [ -z "$JAVA_HOME" ]
then
    echo
    echo $ERR_MSG_JAVA_REQUIRED
    echo
    exit 1
fi

export JAVA_VERSION=$("$JAVA_HOME/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')

if [[ "$JAVA_VERSION" < "1.8" ]]
then
    echo
    echo You are using older java version $JAVA_VERSION
    echo $ERR_MSG_JAVA_REQUIRED
    echo
    exit 1
fi

export SCRIPT_DIRECTORY=$(dirname "$(readlink -f "$0")")
cd "$SCRIPT_DIRECTORY"

export CLI_HOME=.
export REST_CLI_HOME=$CLI_HOME/lib

export CLASSPATH=.:$REST_CLI_HOME/ess_rest_cli.jar:$REST_CLI_HOME/ess_es_server.jar:$REST_CLI_HOME/ess_japi.jar:$REST_CLI_HOME/ess_svp.jar:$REST_CLI_HOME/commons-cli.jar:$REST_CLI_HOME/commons-io.jar:$REST_CLI_HOME/jersey-client.jar:$REST_CLI_HOME/javax.ws.rs-api.jar:$REST_CLI_HOME/jersey-common.jar:$REST_CLI_HOME/hk2-utils.jar:$REST_CLI_HOME/hk2-apijar:$REST_CLI_HOME/javax.inject.jar:$REST_CLI_HOME/hk2-locator.jar:$REST_CLI_HOME/hk2-api.jar:$REST_CLI_HOME/javax-annotation-javax-annotation-api.jar:$REST_CLI_HOME/jackson-annotations.jar:$REST_CLI_HOME/jackson-core.jar:$REST_CLI_HOME/jackson-databind.jar:$REST_CLI_HOME/jackson-mapper-asl-1.9.2.jar:$REST_CLI_HOME/ojdl.jar:$REST_CLI_HOME/jersey-guava.jar:$REST_CLI_HOME/cglib.jar:$REST_CLI_HOME/jackson-core-asl-1.9.2.jar:$JAVA_HOME/db/lib/derby.jar:$REST_CLI_HOME/ojdbc8.jar:$REST_CLI_HOME/ess-platform-common.jar:$REST_CLI_HOME/datasource-model.jar:$REST_CLI_HOME/excel-core.jar:$REST_CLI_HOME/lz4-java.jar:$REST_CLI_HOME/avatica-core.jar:$REST_CLI_HOME/calcite-core.jar:$REST_CLI_HOME/calcite-linq4j.jar:$REST_CLI_HOME/protobuf-java.jar:$REST_CLI_HOME/janino.jar:$REST_CLI_HOME/json-path.jar:$REST_CLI_HOME/checker-qual.jar:$REST_CLI_HOME/jts-core.jar:$REST_CLI_HOME/commons-compiler.jar:$REST_CLI_HOME/guava.jar:$REST_CLI_HOME/failureaccess.jar:$REST_CLI_HOME/slf4j-api.jar:$REST_CLI_HOME/slf4j-nop.jar:$REST_CLI_HOME/commons-lang3.jar:$REST_CLI_HOME/ons.jar:$REST_CLI_HOME/oraclepki.jar:$REST_CLI_HOME/orai18n.jar:$REST_CLI_HOME/osdt_core.jar:$REST_CLI_HOME/osdt_cert.jar:$REST_CLI_HOME/simplefan.jar:$REST_CLI_HOME/ucp.jar:$REST_CLI_HOME/xdb6.jar:$REST_CLI_HOME/esscatalog-model.jar
desertnaut
  • 57,590
  • 26
  • 140
  • 166
sebroux
  • 11
  • 3
  • The file you provide does not appear to make use of any arguments passed to it (eg. `login`, `lcmexport`, etc). Perhaps you have truncated it. – jhnc Jul 05 '23 at 21:26
  • Can you please share the contents of `/tmp/exportLCM_applications.txt`? If it is not "hardcodedapp" (or whatever you are executing manually) then you are comparing apples to oranges and all bets are off. I recommend adding an `echo $application` at the top of the `else` clause to verify that it is what you are expecting. The error appears to be coming from Oracle and is not a shell error. – Vercingatorix Jul 06 '23 at 15:03

1 Answers1

0

I resolved the issue by reading the documentation which says:

To execute multiple CLI commands, add them to any shell script and execute it. In any script you run that contains CLI commands, Oracle recommends you include the following directive before the CLI login statement: For Windows: set ESSCLI_ID=%USERNAME%%random% For Linux: export ESSCLI_ID=whoami$PPID This helps store session information and prevent execution errors when multiple scripts are run concurrently.

https://docs.oracle.com/en/database/other-databases/essbase/21/ugess/download-and-use-command-line-interface.html

desertnaut
  • 57,590
  • 26
  • 140
  • 166
sebroux
  • 11
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 12 '23 at 07:25