xxl-job 報:java.net.BindException: Address already in use: bind
錯誤資訊
初看的時候還以為是埠占用:Address already in use: bind
,不要被錯誤提示矇蔽了,實則是 xxl-job
的執行器註解 @Bean
配置的問題。
2020-12-29 09:24:00.494 INFO 9284,// --- [ Thread-40] com.xxl.rpc.remoting.net.Server : >>>>>>>>>>> xxl-rpc remoting server start success, nettype = com.xxl.rpc.remoting.net.impl.netty_http.server.NettyHttpServer, port = 9991
Exception in thread "Thread-44" java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:504)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:489)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
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:745)
問題定位
在低版本的 xxl-job
中, 初始化 XxlJobSpringExecutor
執行器需要在 @Bean
中加上 initMethod = "start", destroyMethod = "destroy"
,但是在高版本的 xxl-job
(如 2.1.2
)則需要刪除 initMethod = "start", destroyMethod = "destroy"
報錯前
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses());
xxlJobSpringExecutor.setAppName(jobProperties.getAppName());
xxlJobSpringExecutor.setPort(jobProperties.getPort());
xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath());
xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays());
xxlJobSpringExecutor.setIp(jobProperties.getIp());
xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken());
return xxlJobSpringExecutor;
}
解決
把 @Bean
的屬性 initMethod = "start", destroyMethod = "destroy"
刪除即可,程式碼如下:
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses());
xxlJobSpringExecutor.setAppName(jobProperties.getAppName());
xxlJobSpringExecutor.setPort(jobProperties.getPort());
xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath());
xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays());
xxlJobSpringExecutor.setIp(jobProperties.getIp());
xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken());
return xxlJobSpringExecutor;
}
相關文章
- java.net.BindException: Address already in use: JVM_BindJavaIndexExceptionJVM
- java.net.bindexception:address already in use: connectJavaIndexException
- 解決ProtocolHandler ["ajp-nio-8009"] java.net.BindException: Address already in use: bind問題ProtocolJavaIndexException
- startNodeManager埠被佔用:java.net.BindException: Address already in useJavaIndexException
- 解決 eclipse出現 Address already in use: bindEclipse
- Address already in use: JVM_Bind:80 解決方案JVM
- 解決svnserve: Can't bind server socket: Address already in useServer
- Redis 啟動報錯Address already in useRedis
- 解決nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)NginxAI
- bind (ERROR 502): bind(0.0.0.0:8811) failed. Error: Address already in use [98] (埠被佔用)ErrorAI
- 實現dubbo隨機埠,解決重啟Address already in use異常隨機
- efcore This MySqlConnection is already in useMySql
- mysql bind_address如何配置多個地址 mysql bind-address選項MySql
- kafka java.rmi.server.ExportException: Port already in useKafkaJavaServerExportException
- Oracle Database on NFS : unable to lock file - already in use" ErrorOracleDatabaseNFSError
- 重啟docker服務後,容器啟動報錯:Error response from daemon: id already in useDockerError
- 奇怪報錯資訊“db already exists with different case already have”解決方法
- [Vue warn]: The data property "dialogVisible" is already declared as a prop. Use prop default valueVue
- python3 tkinter報錯:_tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by gridPythonErrorIDE
- bind-address如果是127.0.0.1,mysql只接受localhost,不接受遠端連線127.0.0.1MySqllocalhost
- git使用報錯fatal: remote origin already exists.GitREM
- 錯誤: 代理丟擲異常錯誤: java.rmi.server.ExportException: Port already in use: 1099;JavaServerExportException
- Several ports (8005, 8080) required by Tomcatv9.0 Server at localhost are already in use.Tomcat解決方案UITomcatServerlocalhost
- aix Oracle 使用者報錯:Too many processes already existAIOracle
- Xxl-job安裝部署以及SpringBoot整合Xxl-job使用Spring Boot
- crontab工具報錯crontab:you are not authorized to use cron.Sorry.Zed
- kernel 中WiFi模組報錯:device not accepting address .error -71WiFidevError
- 【轉載】Kano Model — Ways to use it and NOT use it
- xxl-job心跳機制
- CRS啟動報錯Failed 3 to bind listening endpointAI
- the "in" use in mysqlMySql
- nginx useNginx
- Spring Boot 整合 xxl-jobSpring Boot
- Thread already joined at **thread
- oracle hint_use_concat_use_nl_with_indexOracleIndex
- JavaScript bind()JavaScript
- javascript bindJavaScript
- Window中安裝gitblit時,IP地址或埠衝突,提示Cannot assign requested address: bind的詳細解決方法Git