Skip to content

[Bug] skywalking swck inject bug #13240

Closed

Description

@hhhhuanzi

Search before asking

  • I had searched in the issues and found no similar issues.

Apache SkyWalking Component

SWCK (apache/skywalking-swck)

What happened

SWCK injects the Java Agent into the /sky/agent directory of the container. However, it fails to start. If the injection is not used and the agent is manually downloaded and built into the container using docker build, the startup works fine.

Environment:

JDK Version: OpenJDK version "21-ea" 2023-09-19
SkyWalking Version: OAP 10.0.0, UI 10.0.0
SWCK Version: 0.9.0
Java Agent Version: 9.4.0-java21

The path of the swck injected agent inside the container: /sky/agent/skywalking-agent.jar
The path of the manually built agent inside the container: /sky2/skywalking-agent.jar

Error Log:

root@demo-6b9c9f9ffb-6fdjm:/app# java -javaagent:/sky/agent/skywalking-agent.jar -jar demo-0.0.1-SNAPSHOT.jar
Picked up JAVA_TOOL_OPTIONS:
DEBUG 2025-05-12 09:25:03.317 main AgentPackagePath : The beacon class location is jar:file:/sky/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2025-05-12 09:25:03.321 main SnifferConfigInitializer : Config file found in /sky/agent/config/agent.config.
...
...
...
INFO 2025-05-12 09:25:07.305 main SkyWalkingAgent : Skywalking agent begin to install transformer ...

. ____ _ __ _ _
/\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |
| .__|| ||| |_, | / / / /
=========|
|==============|/=////

:: Spring Boot :: (v3.4.5)

Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.skywalking.apm.agent.core.meter.MeterService.register(org.apache.skywalking.apm.agent.core.meter.BaseMeter)" because "org.apache.skywalking.apm.agent.core.meter.AbstractBuilder.METER_SERVICE" is null
at org.apache.skywalking.apm.agent.core.meter.AbstractBuilder.build(AbstractBuilder.java:73)
at org.apache.skywalking.apm.agent.core.so11y.AgentSo11y.durationOfInterceptor(AgentSo11y.java:139)
at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInter.intercept(ConstructorInter.java:78)
at ch.qos.logback.classic.spi.LoggingEvent.(LoggingEvent.java)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:424)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:386)
at ch.qos.logback.classic.Logger.log(Logger.java:780)
at org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog.warn(LogAdapter.java:445)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:821)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1362)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1351)
at com.example.wanghuandemo.WanghuanDemoApplication.main(WanghuanDemoApplication.java:10)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 4 more

### Logs from starting with the manually injected agent:
root@demo-6b9c9f9ffb-6fdjm:/app# java -javaagent:/sky2/skywalking-agent.jar -jar demo-0.0.1-SNAPSHOT.jar
Picked up JAVA_TOOL_OPTIONS:
DEBUG 2025-05-12 09:25:03.317 main AgentPackagePath : The beacon class location is jar:file:/sky/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2025-05-12 09:25:03.321 main SnifferConfigInitializer : Config file found in /sky/agent/config/agent.config.
...
...
...
INFO 2025-05-12 09:36:09.188 main SkyWalkingAgent : Skywalking agent begin to install transformer ...

. ____ _ __ _ _
/\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |
| .__|| ||| |_, | / / / /
=========|
|==============|/=////

:: Spring Boot :: (v3.4.5)

2025-05-12 09:36:40.390 [main] INFO com.example.wanghuandemo.WanghuanDemoApplication [TID:N/A] - Starting WanghuanDemoApplication v0.0.1-SNAPSHOT using Java 21-ea with PID 257 (/app/wanghuan-demo-0.0.1-SNAPSHOT.jar started by root in /app)
2025-05-12 09:36:40.416 [main] INFO com.example.wanghuandemo.WanghuanDemoApplication [TID:N/A] - No active profile set, falling back to 1 default profile: "default"
2025-05-12 09:36:51.086 [main] INFO o.s.d.r.config.RepositoryConfigurationDelegate [TID:N/A] - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2025-05-12 09:36:51.923 [main] INFO o.s.d.r.config.RepositoryConfigurationDelegate [TID:N/A] - Finished Spring Data repository scanning in 703 ms. Found 1 JPA repository interface.
2025-05-12 09:36:59.706 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer [TID:N/A] - Tomcat initialized with port 8080 (http)
2025-05-12 09:36:59.813 [main] INFO org.apache.coyote.http11.Http11NioProtocol [TID:N/A] - Initializing ProtocolHandler ["http-nio-8080"]
2025-05-12 09:36:59.824 [main] INFO org.apache.catalina.core.StandardService [TID:N/A] - Starting service [Tomcat]
2025-05-12 09:36:59.825 [main] INFO org.apache.catalina.core.StandardEngine [TID:N/A] - Starting Servlet engine: [Apache Tomcat/10.1.40]

What you expected to happen

swck injected has bug

How to reproduce

1、download java-agent tar on official website。
2、use dockerfile command 'COPY' skywalking folder into container
3、use swck swagent to inject skywalking-java-agent into container
4、exec container,export JAVA_TOOLS_OPTS=''
5、use java -javaagent:/sky/agent/skywalking-agent.jar watch error log
6、use java -javaagent:/sky2/skywalking.jar watch success log。/sky2/skywalking.jar is docker build into container

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Activity

  1. added
    bugSomething isn't working and you are sure it's a bug!
    on May 12, 2025
  2. locked and limited conversation to collaborators on May 12, 2025
  3. converted this issue into a discussion #13241 on May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working and you are sure it's a bug!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions