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

java.lang.IllegalStateException: TTL logger implementation type is already set! type = 0 #550

Closed
BenettChen opened this issue Sep 19, 2023 · 2 comments
Assignees
Labels
❓question Further information is requested

Comments

@BenettChen
Copy link

BenettChen commented Sep 19, 2023

我在使用JavaAgent形式的时候,出现这个异常

Exception in thread "main" java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
  at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.IllegalStateException: TTL logger implementation type is already set! type = 0
  at com.alibaba.ttl.threadpool.agent.internal.logging.Logger.setLoggerImplType(Logger.java:22)
  at com.alibaba.ttl.threadpool.agent.TtlAgent.premain(TtlAgent.java:129)

JVM配置如下:
-Xmx3g -XX:+UseG1GC -XX:MaxGCPauseMillis=300 -javaagent:/opt/service/zhaopin_scf_zpjob/config/lib/transmittable-thread-local-2.14.0.jar

Maven依赖包:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>transmittable-thread-local</artifactId>
    <version>2.14.0</version>
</dependency>
@oldratlee
Copy link
Member

oldratlee commented Sep 19, 2023

......
Caused by: java.lang.IllegalStateException: TTL logger implementation type is already set! type = 0
......

这是防御式检查所抛出的异常(IllegalStateException);
可能和你具体使用/配置方式相关。 @BenettChen

请提供一个 极简、可运行、复现问题的 代码Demo工程。

推荐提供成一个单独的工程(Github repo)。这样可以:

  • 方便大家能排查分析(只提供片段代码、运行结果,排查信息不足)
  • 方便分离不相关的业务实现内容,以及排除可能的业务使用问题
    如使用配置问题、其它业务代码的意外影响

@oldratlee oldratlee added the ❓question Further information is requested label Sep 19, 2023
@BenettChen
Copy link
Author

BenettChen commented Sep 19, 2023

刚我也和中间件团队一起排查了这个问题,发现是:

  • 中间件团队在某些情况下也会使用TTL,应该中间件团队的TTL和业务程序中TTL冲突导致;
  • 我把中间件的TTL关掉调,后面部署就没问题了。

就当一个问题记录吧,后面有人遇到这个异常,先考虑下自己的环境问题,多一个排查方向。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants