So I have been facing issue when I add -Dcom.sun.management.jmxremote to my server vm arguments, it just stops. Is there something obvious that I am missing ? FYI - This is a spring boot application.
Here's how I am starting the server
java \
> -Dcom.sun.management.jmxremote \
> -Dcom.sun.management.jmxremote.ssl=false \
> -Dcom.sun.management.jmxremote.authenticate=false \
> -Dcom.sun.management.jmxremote.port=1099 \
> -Dcom.sun.management.jmxremote.rmi.port=1199 \
> -XX:+HeapDumpOnOutOfMemoryError \
> -XX:+FlightRecorder \
> -server -jar my-app.jar
-Dcom.sun.management.jmxremote and -Dcom.sun.management.jmxremote.port=1099 both give the problem. If I remove them, server starts.
Related
I'm quite new to devops world, and I'm currently learning it. I'm trying to start a docker-compose file with kafka and specific app that interacts with it, following one of the tutorials. It requires to start the java jar with the following parameters:
java -Dcom.sun.management.jmxremote.port=5555 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar build/libs/kafka-streams-scaling-all.jar
The question is - how do I run multiline command with options? I've tried it this way:
autoscaling:
exec:
command:
- java
- |
-Dcom.sun.management.jmxremote.port=5555 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar build/libs/kafka-streams-scaling-all.jar
But it returns in "./docker-compose.yml", line 75, column 9 could not find expected ':' in "./docker-compose.yml", line 76, column 9
and some of the answers on the internet suggest to use > sign:
autoscaling:
exec:
command: >
java -Dcom.sun.management.jmxremote.port=5555 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar build/libs/kafka-streams-scaling-all.jar
But docker doesn't seem to understand the "-" part of the command expected <block end>, but found '-' in "./docker-compose.yml", line 74, column 7
What is the best way to approach the running the java jars with options in docker-compose files?
Wrong indentation
<service_name>:
command: |
java \
-Dcom.sun.management.jmxremote.port=5555 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar build/libs/kafka-streams-scaling-all.jar
This question already has answers here:
Has anyone ever got a remote JMX JConsole to work?
(20 answers)
Closed 7 years ago.
I have a Java 8 application running on a remote Linux server and need to attach a JConsole to it for debugging purposes.
From my local machine I set up a tunnel to the remote machine:
ssh -fN -L 9999:localhost:9999 myuser#1.11.11.111
On the remote machine I run the application with the following system properties:
java -Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
-cp foo.jar:config com.foo.bar.Main config/blah.properties
but when I start the JConsole I get Secure connection failed.
If I click on "Insecure connection" I get
How can I get around this?
I managed to make it working adding an extra system property for the RMI port:
java \
-Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.rmi.port=9999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
-cp foo.jar:config com.foo.bar.Main config/blah.properties
I have my OSGi application launching with the following command in my remote machine:
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=8080 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar bin/felix.jar
And in my local machine I have VisualVM from which I try to connect to the remote JVM instance:
What am I missing?
Thanks!
The comment from #Klara saved my day !!
fixed my connection to the jstad
jstatd -J-Djava.security.policy=all.policy -J-Djava.rmi.server.hostname=hostname-goes-here &
I started tomcat through jsvc as daemon. But after jsvc started, I see double jsvc process.
Process had started by daemon.sh with option start:
start )
"$JSVC" $JSVC_OPTS \
-java-home "$JAVA_HOME" \
-java-home /usr/lib/jvm/jre1.7.0_11 \
-user $TOMCAT_USER \
-pidfile "$CATALINA_PID" \
-wait 10 \
-outfile "$CATALINA_OUT" \
-errfile "&1" \
-classpath "$CLASSPATH" \
"$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMP" \
$CATALINA_MAIN
exit $?
Assuming your question is: Why do I get two processes? This could be because jsvc starts a main daemon process and a child process for the actual work.
I want to profile tomcat server with a java profiler. My profiler runs from the script say run.sh which looks like below:
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly; cannot execute: $JAVACMD"
exit 1
fi
java -javaagent:lib/jborat-agent.jar \
-Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \
-Dch.usi.dag.jborat.liblist="conf/lib.lst" \
-Dch.usi.dag.jp2.outputFilePrefix="output" \
-Dch.usi.dag.jborat.instrumentation="ch.usi.dag.jp2.instrument.AddInstrumentation" \
-Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \
-Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" \
-Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.jar/jp2.jar/jborat-agent.jar/jborat.jar $*
Could somebody please guide me how can I include this profiler in tomcat ?
Is it possible to write something like this CATALINA_OPTS="$CATALINA_OPTS -javaagent:run.sh" in catalina.sh ?
I would really appreciate any help regarding this.
Thanks.
I tried adding options of run.sh (profiler) to setenv.sh as below but does not work. It does not give any error but The server is not starting. I dont know why.
Here is my setenv.sh file:
#!/bin/sh
export CATALINA_OPTS="java -javaagent:lib/jborat-agent.jar \
-Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \
-Dch.usi.dag.jborat.liblist="conf/lib.lst" \
-Dch.usi.dag.jp2.outputFilePrefix="output" \
-Dch.usi.dag.jborat.instrumentation="ch.usi.dag.jp2.instrument.AddInstrumentation" \
-Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \
-Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" \
-Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.jar/jp2.jar/jborat-agent.jar/jborat.jar "
I already answered your exact same question yesterday. Briefly, you want this:
$ export CATALINA_OPTS="-javaagent:lib/jborat-agent.jar -Xss256m -Xms256m \ -Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \ -Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \ -Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.jar"
$ $CATALINA_HOME/bin/startup.sh
I don't understand why you need more than that: your script just adds a bunch of system properties to the JVM launcher: you can do that with $CATALINA_OPTS. If you want to set them somewhat permanently, put the export into bin/setenv.sh and it will automatically be run every time you run bin/startup.sh (and bin/shutdown.sh for that matter).