XXL-JOB 执行器运行报错NoClassDefFoundError HttpObjectAggregator

xxl-job版本为2.3.1

问题描述

执行器启动时不报错,发生任务调度时,任务执行报错如下

2023-04-19 09:35:02.972 WARN  [nioEventLoopGroup-8-2] [] i.n.c.ChannelInitializer [97] --- Failed to initialize a channel. Closing: [id: 0x07ef799a, L:/172.20.2.41:30073 - R:/172.20.0.0:45848]
java.lang.NoClassDefFoundError: Could not initialize class io.netty.handler.codec.http.HttpObjectAggregator
	at com.xxl.job.core.server.EmbedServer$1$3.initChannel(EmbedServer.java:72)
	at com.xxl.job.core.server.EmbedServer$1$3.initChannel(EmbedServer.java:67)
	at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129)
	at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112)
	at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:938)
	at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:609)
	at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46)
	at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1463)
	at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1115)
	at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:650)
	at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:514)
	at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:429)
	at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:486)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

问题原因

经过检查,原因是项目中其他框架也引入了netty,但是版本比xxl-job的低,版本冲突导致找不到类

解决办法

指定netty版本为高版本,经查看,xxl-job的netty为 4.1.82.Final

在pom中添加以下配置

        <dependency>
            <groupId>io.nettygroupId>
            <artifactId>netty-allartifactId>
            <version>4.1.82.Finalversion>
        dependency>

你可能感兴趣的:(java,jvm,spring)