1
votes

I have my service running on my private instance (running outside of Google Cloud) , I am using Tomcat as a webserver. In cdbg_java_agent.ERROR log file I see the following error stack while starting Java Server.

E1025 19:56:10.922689 17636 jni_utils.h:372] GcpHubClient.<init>: java.lang.RuntimeException: Failed to initialize service account authentication
        at com.google.devtools.cdbg.debuglets.java.GcpEnvironment.getMetadataQuery(Unknown Source)
        at com.google.devtools.cdbg.debuglets.java.GcpHubClient.<init>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.google.devtools.cdbg.debuglets.java.ServiceAccountAuth
        at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at com.google.devtools.cdbg.debuglets.java.InternalsClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:278)
        ... 2 more
E1025 19:56:10.923075 17636 jni_bridge.cc:50] Failed to instantiate HubClient Java class
E1025 19:56:10.923120 17636 worker.cc:145] HubClient not available: debugger thread can't continue.

I got info from: https://cloud.google.com/debugger/docs/setup/java I have done

mkdir /opt/cdbg
wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \
    tar xvz -C /opt/cdbg

And I have a file with my credentials at /opt/cdbg/gcp-svc.json

export GOOGLE_APPLICATION_CREDENTIALS="/opt/cdbg/gcp-svc.json"

JAVA_OPTS which are added

   -agentpath:/opt/cdbg/cdbg_java_agent.so 
    -Dcom.google.cdbg.module=javadebug 
    -Dcom.google.cdbg.version=1 
    -Dcom.google.cdbg.auth.serviceaccount.enable=true 
    -Dcom.google.cdbg.auth.serviceaccount.jsonfile=/opt/cdbg/gcp-svc.json

I know GOOGLE_APPLICATION_CREDENTIALS and -Dcom.google.cdbg.auth.serviceaccount.jsonfile is a repetition but having only either one of them also does not give a different result.

2
In case this helps somebody else, I also got here after using Google's OpenJDK image, which as of now, pre-installs the agent without service account support. There's a discussion about that at github.com/GoogleCloudPlatform/cloud-debug-java/issues/8.jon_wu

2 Answers

3
votes

Download the right package that supports service account. cdbg_java_agent_service_account.tar.gz

0
votes

To mention what Erez Haba suggested I tried this one:

sudo wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_service_account.tar.gz | \
sudo tar xvz -C /opt/cdbg

Which did work as expected. +1 to Erez Haba