Application Debugging
Connect to the JVM of a Self Managed Commerce Application
This section outlines how to connect to a Self Managed Commerce application JVM in a Kubernetes deployment. It is intended for developers who are familiar with Java and the Elastic Path application stack. By default the JMX, and JVM (Java Virtual Machine) debug ports are not made accessible via endpoints for security reasons.
Using JMX Console
Procedure
To connect to a JMX port for a deployed Self Managed Commerce application with JConsole or JVisualVM:
Set the parameter
enableJmx
in the Jenkins jobdeploy-or-delete-commerce-stack
.(Optional) Enable JMX user and password authentication by setting the parameter
enableJmxAuth
.Deploy a Self Managed Commerce stack using the job
deploy-or-delete-commerce-stack
.(Optional) Find the JMX username and password, if JMX user and password authentication is enabled.
The username and password are auto-generated and uploaded to a Kubernetes ConfigMap under the keys
JMX_USER
andJMX_PASSWORD
.To access the ConfigMap, access the Kubernetes dashboard of the same Kubernetes cluster as the Self Managed Commerce deployment. Switch to the same namespace as the deployment and open the ConfigMap named
ep-configmap
.Forward the JMX port of the applications in the cluster to your local computer.
See the following command as an example. Replace
${NAMESPACE}
andapp=ep-cm
with the values for your application.cmPodName=$(kubectl get pods -n ${NAMESPACE} -l 'app=ep-cm' -o jsonpath='{.items[*].metadata.name}') kubectl port-forward pod/${cmPodName} -n ${NAMESPACE} 8888:8888
If authentication is disabled, you can open the JMX connection directly from the terminal.
Run the following command to run JConsole:
jconsole localhost:8888
Run the following command to run JVisualVM, if required:
jvisualvm --openjmx 127.0.0.1:8888
If authentication is enabled, run the Java profiler of choice and connect manually using the UI providing the correct username and password from step 4.
note
Disable JMX connections on production environments to avoid performance issues.
Using remote debugger
To connect to the JVM of a Self Managed Commerce application in debug mode from your IDE:
Enable the parameter
enableDebug
in the Jenkins jobdeploy-or-delete-commerce-stack
Deploy a Self Managed Commerce stack using the job
deploy-or-delete-commerce-stack
Forward the debug port of the application in the cluster to your local computer.
See the following command as an example. Replace
${NAMESPACE}
andapp=ep-cm
with the values for your application.cmPodName=$(kubectl get pods -n ${NAMESPACE} -l 'app=ep-cm' -o jsonpath='{.items[*].metadata.name}') kubectl port-forward pod/$cmPodName -n ${NAMESPACE} 1081:1081
Configure the remote debugger in your IDE to connect to
localhost:1081
.note
You can expose both the JMX and debug ports in one step by port forwarding with both ports appended to the command. See the following command as an example:
cmPodName=$(kubectl get pods -n ${NAMESPACE} -l 'app=ep-cm' -o jsonpath='{.items[*].metadata.name}') kubectl port-forward pod/$cmPodName -n ${NAMESPACE} 8888:8888 1081:1081