Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make extension loading more dynamic #754

@grgrzybek

Description

@grgrzybek

When Jolokia agent starts in WAR or Spring (Boot), we have this:

serviceManager.addServices(new ClasspathServiceCreator("services"))

called using org.jolokia.server.core.util.LocalServiceFactory.class.getClassLoader() and we have access to many jars on current classpath (WAR or Spring (Boot) classpath).

However, when we start the agent using -javaagent, the agent JAR is added to system classloader like this:

"main@1" prio=5 tid=0x1 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at jdk.internal.loader.URLClassPath.addURL(URLClassPath.java:250)
      - locked <0x276> (a jdk.internal.loader.URLClassPath)
      - locked <0x279> (a java.util.ArrayDeque)
      at jdk.internal.loader.URLClassPath.addFile(URLClassPath.java:261)
      at jdk.internal.loader.BuiltinClassLoader.appendClassPath(BuiltinClassLoader.java:208)
      at jdk.internal.loader.ClassLoaders$AppClassLoader.appendToClassPathForInstrumentation(ClassLoaders.java:204)

And in many cases (Tomcat, Artemis, ...) the initial classpath (the one specified with -classpath JVM argument) is very short, containing only some bootstrap code that'll create and populate the real classloader (usually from lib/ directory of the server.

So when we want to kepp boot classpath small and also use Jolokia extensions (/META-INF/jolokia/services), we need a way to semi-dynamically add new services to the agent / service manager...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions