elastic / elastic/apm-agent-java

`IndyBootstrapDispatcher` cannot be properly loaded in the Resin environment

Open
#3,807 2 comments 0 reactions 0 assignees View on GitHub
agent-java community
Dominant language
Java
Stars
594
Forks
338
Avg merge
1d 13h
Merged PRs (30d)
25

Description

## Describe the bug
When starting **Resin 3** using the provided startup script ($RESIN_HOME/bin/httpd.sh), the runtime is unable to load `java.lang.IndyBootstrapDispatcher` via the `DynamicClassLoader`.

After some investigation, I found that the startup script ultimately calls the `com.caucho.boot.WatchdogProcess#createProcess` method (located in resin.jar) to launch Resin. This method hardcodes the startup argument `-Djava.system.class.loader=com.caucho.loader.SystemClassLoader`, which replaces the default system class loader.

As a result, when Resin tries to load `IndyBootstrapDispatcher`, the DynamicClassLoader delegates the loading to SystemClassLoader, which is unable to load it. In Resin 3, the `resin.conf` file provides a `tree-node` element to configure special JAR file paths, allowing SystemClassLoader to access the target files. However, the internal implementation is hardcoded to fetch the target entry from the JAR file, like `configuredJars.getJarEntry("java/lang/IndyBootstrapDispatcher.class")`.

The issue is that Elastic has shaded the class, and its actual resource path is represented as `agent/bootstrap/java/lang/IndyBootstrapDispatcher.esclazz`. This mismatch causes the class loading to fail, leading to malfunctioning agent functionality.

All the above is specific to Resin 3. Resin 4 might have the same problem, but I haven't tested it yet.

## Steps to reproduce
1. In the resin.conf file, add the following configuration
```java
-javaagent:/path/to/elastic-apm-agent.jar
-Delastic.apm.log_level=DEBUG
-Delastic.apm.log_file=/path/to/logs/elastic-apm-agent.log
```
2. download the [vulns.jar](https://github.com/baidu-security/openrasp-testcases/releases/download/v1.1.21/vulns.war) to `$RESIN_HOME/webapps`
3. RUN `$RESIN_HOME/bin/httpd.sh start`
4. Access `http://localhost:7040/vulns` through your browser

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.