Skip to content

Custom java agent doesn't work with v5 #1229

@krismarc

Description

@krismarc

@ramonskie, a simple project jar with applicationinsights-agent.jar added on the root archive level

The same works with old ruby based java buildpack

Please note adding APPLICATIONINSIGHTS_CONNECTION_STRING is essential, otherwise it doesn't start the agent and error doesn't occur

I believe this might be some command evaluation problem that leads to running the jar in a wrong way and java's help is getting printed out.

  APPLICATIONINSIGHTS_CONNECTION_STRING: InstrumentationKey=<key-guid>;IngestionEndpoint=https://westeurope-1.in.applicationinsights.azure.com/
  _JAVA_OPTIONS: >-
    -Dhttps.proxyHost=gate.company.com
    -Dhttps.proxyPort=8080
    -Dhttp.proxyHost=gate.company.com
    -Dhttp.proxyPort=8080
    -Dhttp.nonProxyHosts=localhost|*.companyapps-np.com|*.companyapps.com|*.gwpnet.com|*.appcloud.company.com|*.ac.company.com|*.ac-np.company.com|*.company.com
  JAVA_OPTS: >-
    -javaagent:applicationinsights-agent.jar
   2026-04-02T13:44:39.12+0200 [CELL/0] OUT Downloading droplet...
   2026-04-02T13:44:45.23+0200 [CELL/0] OUT Downloaded droplet (239.5M)
   2026-04-02T13:44:45.23+0200 [CELL/0] OUT Starting health monitoring of container
   2026-04-02T13:44:45.40+0200 [APP/PROC/WEB/0] OUT Invoking pre-start scripts.
   2026-04-02T13:44:45.44+0200 [APP/PROC/WEB/0] OUT Created symlink: /home/vcap/app/BOOT-INF/lib/java-cfenv-3.5.0.jar -> /home/vcap/deps/0/java_cf_env/java-cfenv-3.5.0.jar
   2026-04-02T13:44:45.44+0200 [APP/PROC/WEB/0] OUT Created symlink: /home/vcap/app/BOOT-INF/lib/client-certificate-mapper-2.0.1.jar -> /home/vcap/deps/0/client_certificate_mapper/client-certificate-mapper-2.0.1.jar
   2026-04-02T13:44:45.44+0200 [APP/PROC/WEB/0] OUT Invoking start command.
   2026-04-02T13:44:45.45+0200 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=129700K -XX:ReservedCodeCacheSize=240M -Xss1M -Xmx406875K
   2026-04-02T13:44:45.45+0200 [APP/PROC/WEB/0] ERR Picked up _JAVA_OPTIONS: -Dhttps.proxyHost=gate.company.com -Dhttps.proxyPort=8080 -Dhttp.proxyHost=gate.company.com -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=localhost|*.companyapps-np.com|*.companyapps.com|*.gwpnet.com|*.appcloud.company.com|*.ac.company.com|*.ac-np.company.com|*.company.com
   2026-04-02T13:44:46.07+0200 [APP/PROC/WEB/0] ERR OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
   2026-04-02T13:44:46.37+0200 [APP/PROC/WEB/0] OUT 2026-04-02 11:44:46.373Z INFO  c.m.a.a.i.c.ConfigurationBuilder - Some telemetry may be sampled out because a default sampling configuration was added in version 3.4.0 to reduce the default billing cost. You can set the sampling configuration explicitly: https://learn.microsoft.com/azure/azure-monitor/app/java-standalone-config#sampling
   2026-04-02T13:44:48.53+0200 [APP/PROC/WEB/0] OUT 2026-04-02 11:44:48.534Z INFO  c.m.applicationinsights.agent - Application Insights Java Agent 3.6.2 started successfully (PID 7, JVM running for 3.077 s)
   2026-04-02T13:44:48.53+0200 [APP/PROC/WEB/0] OUT 2026-04-02 11:44:48.534Z INFO  c.m.applicationinsights.agent - Java version: 21.0.10, vendor: BellSoft, home: /home/vcap/deps/0/jre/jre-21.0.10
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR Usage: java [options] <mainclass> [args...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR (to execute a class)
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR or  java [options] -jar <jarfile> [args...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR (to execute a jar file)
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR or  java [options] -m <module>[/<mainclass>] [args...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR java [options] --module <module>[/<mainclass>] [args...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR (to execute the main class in a module)
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR or  java [options] <sourcefile> [args]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR (to execute a single source-file program)
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR Arguments following the main class, source file, -jar <jarfile>,
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -m or --module <module>/<mainclass> are passed as the arguments to
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR main class.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR where options include:
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -client       to select the "client" VM
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -cp <class search path of directories and zip/jar files>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -classpath <class search path of directories and zip/jar files>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --class-path <class search path of directories and zip/jar files>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR A : separated list of directories, JAR archives,
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR and ZIP archives to search for class files.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -p <module path>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --module-path <module path>...
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR A : separated list of elements, each element is a file path
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR to a module or a directory containing modules. Each module is either
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR a modular JAR or an exploded-module directory.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --upgrade-module-path <module path>...
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR A : separated list of elements, each element is a file path
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR to a module or a directory containing modules to replace
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR upgradeable modules in the runtime image. Each module is either
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR a modular JAR or an exploded-module directory.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --add-modules <module name>[,<module name>...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR root modules to resolve in addition to the initial module.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR ALL-MODULE-PATH.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --enable-native-access <module name>[,<module name>...]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR modules that are permitted to perform restricted native operations.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR <module name> can also be ALL-UNNAMED.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --list-modules
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR list observable modules and exit
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -d <module name>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --describe-module <module name>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR describe a module and exit
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --dry-run     create VM and load main class but do not execute main method.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR The --dry-run option may be useful for validating the
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR command-line options such as the module system configuration.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --validate-modules
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR validate all modules and exit
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR The --validate-modules option may be useful for finding
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR conflicts and other errors with modules on the module path.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -D<name>=<value>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR set a system property
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -verbose:[class|module|gc|jni]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR enable verbose output for the given subsystem
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -version      print product version to the error stream and exit
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --version     print product version to the output stream and exit
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -showversion  print product version to the error stream and continue
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --show-version
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR print product version to the output stream and continue
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --show-module-resolution
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR show module resolution output during startup
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -? -h -help
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR print this help message to the error stream
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --help        print this help message to the output stream
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -X            print help on extra options to the error stream
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --help-extra  print help on extra options to the output stream
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -ea[:<packagename>...|:<classname>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -enableassertions[:<packagename>...|:<classname>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR enable assertions with specified granularity
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -da[:<packagename>...|:<classname>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -disableassertions[:<packagename>...|:<classname>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR disable assertions with specified granularity
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -esa | -enablesystemassertions
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR enable system assertions
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -dsa | -disablesystemassertions
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR disable system assertions
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -agentlib:<libname>[=<options>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR load native agent library <libname>, e.g. -agentlib:jdwp
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR see also -agentlib:jdwp=help
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -agentpath:<pathname>[=<options>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR load native agent library by full pathname
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -javaagent:<jarpath>[=<options>]
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR load Java programming language agent, see java.lang.instrument
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR -splash:<imagepath>
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR show splash screen with specified image
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR HiDPI scaled images are automatically supported and used
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR if available. The unscaled image filename, e.g. image.ext,
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR should always be passed as the argument to the -splash option.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR The most appropriate scaled image provided will be picked up
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR automatically.
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR See the SplashScreen API documentation for more information
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR @argument files
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR one or more argument files containing options
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --disable-@files
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR prevent further argument file expansion
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --enable-preview
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR allow classes to depend on preview features of this release
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR To specify an argument for a long option, you can use --<name>=<value> or
   2026-04-02T13:44:48.54+0200 [APP/PROC/WEB/0] ERR --<name> <value>.
   2026-04-02T13:44:48.58+0200 [APP/PROC/WEB/0] OUT Exit status 1
   2026-04-02T13:44:48.58+0200 [CELL/SSHD/0] OUT Exit status 0
   2026-04-02T13:44:54.26+0200 [CELL/0] OUT Cell 19a35bde-f432-4789-93e7-54442219ad63 stopping instance 917f441c-ace0-400b-5c9c-da68
   2026-04-02T13:44:54.26+0200 [CELL/0] OUT Cell 19a35bde-f432-4789-93e7-54442219ad63 destroying container for instance 917f441c-ace0-400b-5c9c-da68
   2026-04-02T13:44:54.29+0200 [API/9] OUT Process has crashed with type: "web"

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