目录
报错
很奇怪的一个问题,项目运行正常,debug启动直接报错,运行不起来
java.lang.ClassNotFoundException: kotlinx.coroutines.debug.AgentPremain
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:304)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Exception in thread "main" FATAL ERROR in native method: processing of -javaagent failed
Disconnected from the target VM, address: '127.0.0.1:52371', transport: 'socket'
原因
看错误分析问题:
- kotlinx 没有安装,新版本用kotlinx语言
- jdk路径不正确或未正确配置
- 启动类vm各种参数添加尝试
开始一个一个实验,都以失败告终,因为正常run是可以启动的,其实这些东西应该都是正确的
解决方法
在查阅了stackoverflow和Jetbrains的Youtrack网站中相关问题后,终于找到了问题,是因为在idea2021.2中使用了kotlin的协程库kotlinx-coroutines-core导致出现了该问题,具体解决方式是在idea的设置中禁用coroutine agent即可。
似乎是默认启用了携程代理,禁用之后就恢复正常了。
重新debugger启动项目,
OK,成功解决了。