Skip to content

Dynamic Attach to Tomcat process fails with NullPointerException #612

@danbtl

Description

@danbtl

Attempting to attach to a Tomcat 9.0.4 process:

java -jar opentracing-specialagent-1.7.4.jar ${PID_OF_TOMCAT}

Throws the following Exception in the Tomcat process:

Terminating initialization of SpecialAgent due to:
java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.getResourceAsStream(String)" because the return value of "java.lang.Thread.getContextClassLoader()" is null
	at io.opentracing.contrib.specialagent.AssembleUtil.loadProperties(AssembleUtil.java:881)
	at io.opentracing.contrib.specialagent.SpecialAgent.init(SpecialAgent.java:152)
	at io.opentracing.contrib.specialagent.SpecialAgent.premain(SpecialAgent.java:138)
	at io.opentracing.contrib.specialagent.SpecialAgent.premain(SpecialAgent.java:119)
	at io.opentracing.contrib.specialagent.SpecialAgent.agentmain(SpecialAgent.java:109)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:513)

Java Version:

# java -version
openjdk version "18.0.1.1" 2022-04-22
OpenJDK Runtime Environment (build 18.0.1.1+2)
OpenJDK 64-Bit Server VM (build 18.0.1.1+2, mixed mode)

Not sure if I'm doing something wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions