I had a simple shell script to attach jolokia jvm agent to a jvm process, the agent starts fine when the script is run locally, but when it is called within
chef recipe, it fails to start.
The script to start jolokia agent
#!/bin/bash
port=8787
jolokia_agent=/tool/jolokia/jolokia-jvm-1.2.2-agent.jar
JVM_PROCESS_NAME='AJavaService'
JVM_PROCESS_ID=$(java -jar $jolokia_agent list | grep $JVM_PROCESS_NAME | awk '{print $1}')
echo $JVM_PROCESS_ID
java -jar $jolokia_agent --host=$(hostname) --port=$port start $JVM_PROCESS_ID
This is the chef recipe to call above script
execute "Start jolokia agent process " do
user service_user
command "sh -x #{jolokia_dir}/start_jolokia.sh"
end
The error that chef-client runs the recipe:
InvocationTarget class com.sun.tools.attach.VirtualMachine (command: start) : null
I have no idea why jolokia fails to start via chef script. Anyone is seeing similar issue?