Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 请求mocker保存报错:“send mock data unhandled error” #529

Open
1 of 2 tasks
shichanglin5 opened this issue Jul 11, 2024 · 3 comments · May be fixed by #577
Open
1 of 2 tasks

[Bug] 请求mocker保存报错:“send mock data unhandled error” #529

shichanglin5 opened this issue Jul 11, 2024 · 3 comments · May be fixed by #577
Labels
bug 🐞 Something isn't working

Comments

@shichanglin5
Copy link
Contributor

shichanglin5 commented Jul 11, 2024

Search before asking

  • I have searched the existing issues before asking.

AREX Test Service

AREX Java Agent (arextest/arex-agent-java)

Current Behavior

报错截图如下
WeChatWorkScreenshot_6e4f7969-c34f-46a7-b6de-567d5fec1238

日志信息

2024-07-11 21:43:28:558 [arex-data-save-handler-4-thread-1] WARN io.arex.inst.runtime.log.LogManager - [[title=arex.saveDataLoop]]send mock data unhandled error: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "original" is null
2024-07-11 21:43:28:558 [arex-data-save-handler-4-thread-1] WARN io.arex.inst.runtime.log.LogManager - [[title=arex.saveDataLoop]]send mock data unhandled error: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "original" is null

问题排查:defaultSerializer 为空导致,debug跟踪代码发现 ServiceLoader 只加载了两个serializer,不包含 io.arex.foundation.serializer.jackson.JacksonSerializer#JacksonSerializer;后续在保存 mocker 时,由于 defaultSerializer 为空导致程序执行异常,后续录制的mocker无法保存
截图中的 classLoader 是 appClassLoader,如果是 spring 程序的话,是 tomcat loader,不会有问题
WeChatWorkScreenshot_38243b58-2030-4796-acb3-0577241d3893

Expected Behavior

一般的场景:tomcat loader 加载时,会包含 io.arex.foundation.serializer.jackson.JacksonSerializer#JacksonSerializer
WeChatWorkScreenshot_0c1eadb0-26ab-4515-acde-ecef6356ca30

Steps To Reproduce

非 tomcate 程序:如下截图的的 xxl 实例程序(jdk17):
image

复现:
1、构建 arex agent,用jdk17
2、指定 agent 挂载参数启动 xxl-job-executor-sample-frameless
3、下发一个调度请求到 xxl-job-executor-sample-frameless 程序(开始录制)
4、接着会看到报错日志:
WeChatWorkScreenshot_6e4f7969-c34f-46a7-b6de-567d5fec1238

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!
@shichanglin5 shichanglin5 added the bug 🐞 Something isn't working label Jul 11, 2024
@YongwuHe
Copy link
Collaborator

@shichanglin5 能否搜索一下这个日志 Unable to load class: 看看加载jacksonSerializer时报了啥错?

@shichanglin5
Copy link
Contributor Author

@YongwuHe
我 debug 排查了下,是因为当 jackson 不存在时,arex agent 将 jackson 相关 jar 包添加到 class loader 报错了:

WeChatWorkScreenshot_3ea95eb3-6c71-485b-87e9-7920514d21ab

这个是 jdk 模块化设计导致的,必须在应用启动命令配置相关jdk 内部模块导出后才能使用反射获取非 public 方法,所以添加如下参数到命令行问题解决:

--add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED

@shichanglin5
Copy link
Contributor Author

但上面添加命令行参数的解决方案不太好,而且这里问题是 arex agent 对 jdk的版本不兼容问题导致的,所以 arex agent 增加兼容性处理的方案是首选的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
2 participants