Jvm Agent failed to start when is called via chef recipe

classic Classic list List threaded Threaded
2 messages Options
hmlhse hmlhse
Reply | Threaded
Open this post in threaded view
|

Jvm Agent failed to start when is called via chef recipe

This post was updated on .
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?
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Jvm Agent failed to start when is called via chef recipe

The reason is very likely a permission problem.

In order to attach to a running process you need to run under the exact same UID as the process you are attaching to. It is *not* enough to be root !

Could you check whether this is the case with your Chef recipe ?
... roland