Disable tracking of Spring Beans and Class Loader Resources


Overview of the Issue

This issue occurs in one of the following scenarios:

  1. An organization runs a Java Springboot Application that uses the Springboot Actuator Health Check. After adding the vFunction Agent, the Actuator Health Check never completes as expected
  2. The Application uses Java version 17 and Spring version 6.1 which are not compatible with Spring Tracking due to a Java 17 Known Issue
  3. An error is generated in the Application’s logging that Class Loader Resources are not loading properly after adding the vFunction Agent. The Application fails to start after this error. For example:
Sample #1
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventHandlerSubscriber': Invocation of init method failed
  1. An Application contains a large number of Spring Beans. When starting the Application with the vFunction Agent, the loading time causes the Application’s startup process to time out or to exceed an acceptable threshold of time for the organization

Steps to Resolve the Issue

Take the following steps to resolve this issue:

  1. SSH or RDP to the VM running the Application where the vFunction Agent is installed
  2. Open the installation.yaml associated with the instance
  • Linux Sudo sample location: /etc/sysconfig/vfunction/installation/instances/default-java/installation.yaml
  • Linux Sudoless sample location: /tmp/vfunction/etc/sysconfig/vfunction/installation/instances/default-java/installation.yaml
  • Windows sample location: C:\vfunction\config\installation\instances\default-java\installation.yaml
  1. Modify the agent.disable_spring setting:
### BEFORE
agent:
  disable_spring: false  


### AFTER
agent:
  disable_spring: true  
  1. Run the upgrade.sh script
  • Linux Sudo sample upgrade flow: sudo bash /opt/vfunction/controller-installation/upgrade.sh -i default-java
  • Linux Sudoless sample upgrade flow: bash /tmp/vfunction/opt/vfunction/controller-installation/upgrade.sh -i default-java
  • Windows sample upgrade flow: powershell -NoProfile -ExecutionPolicy unrestricted -Command “C:\vfunction\controller-installation\upgrade.ps1 -instance default-java”
  1. Restart the JVM

Additional Background

Setting the installation.yaml’s disable_spring: true modifies the vFunction Agent’s etc/sysconfig/vfunction/installation/agent/instances/$INSTANCE_NAME/vfunction-runtime-override.properties file to turn off a number of Spring Object Tracking settings are turned off.

A more nuanced approach to disabling Spring Object Tracking may be to disable one or some Spring Tracking settings while leaving some enabled.

To disable some but not all Spring Object Tracking settings:

  1. In a text editor, open the etc/sysconfig/vfunction/installation/instances/$INSTANCE_NAME/installation.yaml
  2. Add the following settings
### BEFORE
agent:
  override_properties:
#    - key=value

### AFTER
agent:
  override_properties:
    - com.vfunction.runtime.config.tracking.classloaderresources.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.singleton.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.prototype.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.session.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.request.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.globalsession.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.application.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.websocket.tracking.enabled=false
    - com.vfunction.runtime.config.aop.xml.spring.unknown.tracking.enabled=false
  1. As desired, set one or more values to true in the agent.override_properties
  2. Save and close the file
  3. Run the upgrade script
  • Linux Sudo sample upgrade flow: sudo bash /opt/vfunction/controller-installation/upgrade.sh -i default-java
  • Linux Sudoless sample upgrade flow: bash /tmp/vfunction/opt/vfunction/controller-installation/upgrade.sh -i default-java
  • Windows sample upgrade flow: powershell -NoProfile -ExecutionPolicy unrestricted -Command “C:\vfunction\controller-installation\upgrade.ps1 -instance default-java”