com.yourkit.api.Controller not found in JBoss 6.4.5.GA

Questions about YourKit Java Profiler
Post Reply
mcasalino
Posts: 2
Joined: Mon Jul 16, 2018 11:17 am

com.yourkit.api.Controller not found in JBoss 6.4.5.GA

Post by mcasalino »

Hi everybody,

We are trying to use the Yourkit Controller API (https://www.yourkit.com/docs/java/api/c ... oller.html) in a spring web application deployed in JBoss 6.4.5.GA to control the Yourkit agent while the application is running.

The issue we are facing is that the com.yourkit.api.Controller class cannot be found when we try to instantiate the controller:

Code: Select all

Caused by: java.lang.NoClassDefFoundError: com/yourkit/api/Controller
        at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_141]
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) [rt.jar:1.8.0_141]
        at java.lang.Class.getDeclaredMethods(Class.java:1975) [rt.jar:1.8.0_141]
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) [spring-core-4.3.15.RELEASE.jar:4.3.15.RELEASE]
        at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) [spring-core-4.3.15.RELEASE.jar:4.3.15.RELEASE]
        at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) [spring-core-4.3.15.RELEASE.jar:4.3.15.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247) [spring-beans-4.3.15.RELEASE
.jar:4.3.15.RELEASE]
        ... 32 more
Caused by: java.lang.ClassNotFoundException: com.yourkit.api.Controller
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) [rt.jar:1.8.0_141]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [rt.jar:1.8.0_141]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) [rt.jar:1.8.0_141]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [rt.jar:1.8.0_141]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:386) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
        ... 39 more
However, if we remove the Yourkit agent (i.e., remove the -agentpath option), the class is correctly found, but of course we cannot instantiate the controller because no agent is attached to the application:

Code: Select all

Exception caught when initializing controller
, java.lang.Exception: To profile application, you should run it with the profiler agent
        at com.yourkit.api.Controller.getUsedPort(Controller.java:153)
        at com.yourkit.api.Controller.<init>(Controller.java:58)
        at com.amadeus.rulesevaluation.rulesengines.YourKitController.initController(YourKitController.java:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
We included the Yourkit controller classes (yjp-controller-api-redist.jar) both in the webapp WAR and directly in JBoss as a custom module. We also tried to add the following Java options:

Code: Select all

-Dorg.osgi.framework.bootdelegation=com.yourkit.*,com.yourkit.api.*,com.yourkit.runtime.*
-Djboss.modules.system.pkgs=com.yourkit,com.yourkit.api,com.yourkit.runtime
without any success. Finally we tried to include "disableall" among the agent's configuration options, again without any success.

We are using Yourkit 2018.04-b75. Please find below some example agent logs (with disableall option):

Code: Select all

18.04-75 0.014: Log file: /remote/users/mcasalino/.yjp/log/jboss-modules-31183.log
18.04-75 0.014: Command line:
  /gctmp/mcasalino/amr_tmp/amr/pack/JVA/bin/java
  -D[Standalone]
  -server
  -XX:+UseCompressedOops
  -verbose:gc
  -Xloggc:/gctmp/mcasalino/amr_tmp/amr/data/log/amrinst/gc.log
  -XX:+PrintGCDetails
  -XX:+PrintGCDateStamps
  -XX:+UseGCLogFileRotation
  -XX:NumberOfGCLogFiles=5
  -XX:GCLogFileSize=3M
  -XX:-TraceClassUnloading
  -XX:+HeapDumpOnOutOfMemoryError
  -XX:+DisableExplicitGC
  -XX:+PrintFlagsFinal
  -Xms8g
  -Xmx8g
  -XX:+UseG1GC
  -agentpath:/gctmp/mcasalino/yourkit-agent/libyjpagent.so=delay=30000,listen=all,port=20001,disableall,debug=all
  -Dorg.osgi.framework.bootdelegation=com.yourkit.*,com.yourkit.api.*,com.yourkit.runtime.*
  -Djboss.modules.system.pkgs=com.yourkit,com.yourkit.api,com.yourkit.runtime
  -XX:HeapDumpPath=/gctmp/mcasalino/amr_tmp/com/core
  -agentlib:jdwp=transport=dt_socket,address=10088,server=y,suspend=n
  -Dorg.jboss.boot.log.file=/gctmp/mcasalino/amr_tmp/amr/data/log/amrinst/server.log
  -Dlogging.configuration=file:/gctmp/mcasalino/amr_tmp/amr/conf/jboss/configuration/logging.properties
  -jar
  /gctmp/mcasalino/amr_tmp/amr/pack/JBS/jboss-modules.jar
  -mp
  /gctmp/mcasalino/amr_tmp/amr/pack/JBS/modules:/gctmp/mcasalino/amr_tmp/amr/pack/OJF/modules
  -jaxpmodule
  javax.xml.jaxp-provider
  org.jboss.as.standalone
  -Djboss.home.dir=/gctmp/mcasalino/amr_tmp/amr/pack/JBS
  -Djboss.server.base.dir=/gctmp/mcasalino/amr_tmp/amr
  -Djboss.server.base.dir=/gctmp/mcasalino/amr_tmp/amr
  -Djboss.server.config.dir=/gctmp/mcasalino/amr_tmp/amr/conf/jboss/configuration
  -Djboss.server.log.dir=/gctmp/mcasalino/amr_tmp/amr/data/log/amrinst
  -Djboss.server.data.dir=/gctmp/mcasalino/amr_tmp/amr/data
  -Dojf.jboss.deploy.dir=/gctmp/mcasalino/amr_tmp/amr/java/deployments
  -Djboss.bind.address=172.16.99.250
  -Djboss.bind.address.management=172.16.99.250
  -Dfile.encoding=UTF-8
  -Djboss.server.temp.dir=/gctmp/mcasalino/amr_tmp/amr/data/tmp/amrinst
  -Djava.io.tmpdir=/gctmp/mcasalino/amr_tmp/amr/data/tmp/amrinst
  -Djava.util.prefs.systemRoot=/gctmp/mcasalino/amr_tmp/amr/data/tmp/amrinst/.java
  -Djava.util.prefs.userRoot=/gctmp/mcasalino/amr_tmp/amr/data/tmp/amrinst/.java
  -Djboss.server.name=amr
  -Djboss.http.port=10096
  -Djboss.management.native.port=10098
  -Djboss.remoting.port=10097
  -Djboss.management.http.port=10099
  -Dojf.duwrapper.type=amrtype
  -Dojf.duwrapper.instance=amrinst
  -Dojf.duwrapper.group=amrgroup
  -Dojf.node.name=LOY
  -Dlogging.config=classpath:/log4j.prod.xml
  -Dlog4j.configuration=log4j.prod.xml
  -DJTRACER_CONFIG=/gctmp/mcasalino/amr_tmp/amr/data/jtracer/ojf.traceconf
  -Dojf.dynamic.connectivity=true
  -Dojf.polling.interval=3600
  -Dojf.agent.port=10090
  -Dojf.edge.http.port=10089
  -DREF_SYNCHRO_LOC_DIR=/gctmp/mcasalino/amr_tmp//amr/data/rfd/
  -DREF_SYNCHRO_FFP_NAME=ref_synchro.ffp
  --debug
  10088
18.04-75 0.014: Executable: /remote/releasing/rnd-aqg/ojf/components/Java/Pack/1-8-0-141/Release/bin/java
18.04-75 0.014: uname:
  sysname: Linux
  release: 2.6.32.23-0.3-default
  version: #1 SMP 2010-10-07 14:57:45 +0200
  machine: x86_64
18.04-75 0.014: Linux; 64-bit process
18.04-75 0.014: hid: 36022999494395V52321V737529333X8Z7 64-bit machine
18.04-75 0.014: Today is 20180713
18.04-75 0.014: full_build_stamp: 2018.04.75 201806291430
18.04-75 0.014: Agent library path: /gctmp/mcasalino/yourkit-agent/libyjpagent.so
18.04-75 0.014: getTimeNsInfo: "monotonic_raw"
18.04-75 0.014: Agent_OnLoad: orig_options=delay=30000,listen=all,port=20001,disableall,debug=all
  full_options=delay=30000,listen=all,port=20001,disableall,debug=all
18.04-75 0.014: phase: 1
18.04-75 0.014: jvmtiVersion: 30010203
18.04-75 0.014: vendor: Oracle Corporation
18.04-75 0.014: version: 25.141-b32
18.04-75 0.014: info: mixed mode, sharing
18.04-75 0.014: isJava6: 0
18.04-75 0.014: session_id: 133931496690511 (1531499343,31183)
18.04-75 0.016: line_method: 1
18.04-75 0.016: can_generate_exception_events: explicitly disabled with a startup option
18.04-75 0.016: can_suspend: optional capability is not available; is_debugger=1
18.04-75 0.025: Reusing existing jar file: /tmp/yjp201806291430.jar
18.04-75 0.025: JVMTI 30010203; 25.141-b32; Oracle Corporation; mixed mode, sharing
18.04-75 0.032: Successfully registered probes: 1
  Registered: .AgentLoadingSupport
    class: .AgentLoadingSupport$JBoss
    class: .AgentLoadingSupport$OSGi1
    class: .AgentLoadingSupport$OSGi2
    class: .AgentLoadingSupport$OSGi3
18.04-75 0.117: agentStart: 1
18.04-75 0.117: agentStart: 2
18.04-75 0.117: agentStart: OK
18.04-75 0.151: vmInit: 1
18.04-75 0.152: vmInit: 2
18.04-75 0.152: agentInit: 1
18.04-75 0.152: agentInit: Core loaded
18.04-75 0.155: setTriggers:

18.04-75 0.219: setTriggers: to unregister: 0
18.04-75 0.219: setTriggers: method listeners to register: 0
18.04-75 0.219: setTriggers: OK
18.04-75 0.219: ourUnsafe: true
18.04-75 0.219: shmem 42341490: OK
18.04-75 0.220: shmem 4234148E: OK
18.04-75 0.275: socket timeout: 30000
18.04-75 0.275: YourKit Java Profiler agent is listening on port 20001, "listen=all"
18.04-75 0.275: *** HINT ***: To get profiling results, connect to the application from the profiler UI
18.04-75 0.275: agentInit: Core.init() called
18.04-75 0.276: agentInit: OK
18.04-75 0.276: vmInit: 3
18.04-75 0.276: onStartProfiling: entering...
18.04-75 0.276: onStartProfiling: done
18.04-75 0.276: vmInit: OK
18.04-75 0.403: instrumented by probe: .AgentLoadingSupport$JBoss -> org.jboss.modules.PropertyReadAction.run() java.lang.String
18.04-75 0.403: org.jboss.modules.PropertyReadAction
18.04-75 0.403: [m: 10097 91] total classes: processed=1 instrumented=1 0ms
18.04-75 30.278: GcPauseCounter: installed to G1 Young Generation
18.04-75 30.278: GcPauseCounter: installed to G1 Old Generation
18.04-75 126.212: vmDeath: 1
18.04-75 126.212: vmDeath: 2
18.04-75 126.213: vmDeath: 3
18.04-75 126.213: vmDeath: 4
18.04-75 126.213: vmDeath: OK
Do you know how to explain that the com.yourkit.api.Controller class somehow disappears to the JBoss classloader only when the agent is attached? Notice that we manage to have the very same scenario (namely control the profiler from applicative code) work perfectly when profiling a standalone Java application without JBoss involved.

Kind regards,
Matteo
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: com.yourkit.api.Controller not found in JBoss 6.4.5.GA

Post by Anton Katilin »

Hello Matteo,

You should start with the agent and add yjp-controller-api-redist.jar to a class path. This must be a jboss classloading issue that prevents classes in yjp-controller-api-redist.jar from loading.

Please try adding yjp-controller-api-redist.jar to the bootclasspath with -Xbootclasspath/a:<path>. Does this work?

Best regards,
Anton
mcasalino
Posts: 2
Joined: Mon Jul 16, 2018 11:17 am

Re: com.yourkit.api.Controller not found in JBoss 6.4.5.GA

Post by mcasalino »

Hi Anton,

It works! Thanks a lot.

Kind regards,
Matteo
Post Reply