-XX: OnOutOfMemoryError = "<cmd> <arg>" gives an error: could not find or load the main class <arg>
I set JAVA_OPTS as
export JAVA_OPTS="$JAVA_OPTS -server -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log -Dcom.sun.management.jmxremote.ssl=false -Xms100m -Xmx100m -XX:MaxPermSize=5M -XX:ReservedCodeCacheSize=100m -Xss100k -XX:NewRatio=2 -XX:+UseParallelOldGC -XX:+UseParallelGC -XX:CompileThreshold=100 -XX:HeapDumpPath=/usr/share/$package -XX:-HeapDumpOnOutOfMemoryError -XX:OnError=$TEMP_CMD -XX:OnOutOfMemoryError=$TEMP_CMD"
then I run the command "trinidad -p"
In $ TEMP_CMD, if I use the command without any arguments, an OutOfMemoryError occurs and the $ TMP_CMD command is run. But if I use any argument with the command, then the following output is displayed
Error: Could not find or load main class <arg>
arg is an argument
Can someone give me a solution?
Are there any changes to the trinidad.yml file or any other cofig file?
0
1 answer
Try
export JAVA_OPTS="... \"-XX:OnError=$TEMP_CMD\" ..."
or
export JAVA_OPTS='... "-XX:OnError=$TEMP_CMD" ...'
Bash eval http://www.grymoire.com/Unix/Quote.html.
.
test.sh
JAVA_OPTS="$JAVA_OPTS -Xmx32m '-XX:OnOutOfMemoryError=echo %p'"
java $JAVA_OPTS Test
$ bash -x ./test.sh
+ JAVA_OPTS=' -Xmx32m '\''-XX:OnOutOfMemoryError=echo %p'\'''
+ java -Xmx32m ''\''-XX:OnOutOfMemoryError=echo' '%p'\''' Test
Exception in thread "main" java.lang.NoClassDefFoundError: '-XX:OnOutOfMemoryError=echo
.
JAVA_OPTS="$JAVA_OPTS -Xmx32m -XX:OnOutOfMemoryError=\"echo %p\""
java $JAVA_OPTS Test
$ bash -x ./test.sh
+ JAVA_OPTS=' -Xmx32m -XX:OnOutOfMemoryError="echo %p"'
+ java -Xmx32m '-XX:OnOutOfMemoryError="echo' '%p"' Test
Exception in thread "main" java.lang.NoClassDefFoundError: %p"
.
-x bash google , w51 ws: http://mywiki.wooledge.org/BashFAQ/050.
.
1) script,
JAVA_OPTS+=" -Xmx32m -XX:OnOutOfMemoryError=/usr/tmp/test/oom.sh"
java $JAVA_OPTS Test
2) OnOutOfMemoryError
JAVA_OPTS="$JAVA_OPTS -Xmx32m"
java $JAVA_OPTS -XX:OnOutOfMemoryError="echo %p" Test
$ bash -x ./test.sh
+ JAVA_OPTS=' -Xmx32m'
+ /usr/java/jdk1.6.0_16/bin/java -Xmx32m '-XX:OnOutOfMemoryError=echo %p' Test
#
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="echo %p"
# Executing /bin/sh -c "echo 1639"...
1639
+5