最近在搭建RocketMQ5.0,然后按照官方流程:https://rocketmq.apache.org/zh/docs/quickStart/02quickstart
先启动namesrv完,再启动broker的时候遇到以下错误。
java.lang.IllegalAccessError: class org.apache.rocketmq.common.UtilAll (in unnamed module @0x4bde3f8a) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x4bde3f8a
at org.apache.rocketmq.common.UtilAll.viewed(UtilAll.java:720)
at org.apache.rocketmq.common.UtilAll.cleanBuffer(UtilAll.java:684)
at org.apache.rocketmq.store.logfile.DefaultMappedFile.cleanup(DefaultMappedFile.java:470)
at org.apache.rocketmq.store.ReferenceResource.release(ReferenceResource.java:63)
at org.apache.rocketmq.store.ReferenceResource.shutdown(ReferenceResource.java:47)
at org.apache.rocketmq.store.logfile.DefaultMappedFile.destroy(DefaultMappedFile.java:481)
at org.apache.rocketmq.store.index.IndexFile.destroy(IndexFile.java:97)
at org.apache.rocketmq.store.index.IndexService.load(IndexService.java:72)
at org.apache.rocketmq.store.DefaultMessageStore.load(DefaultMessageStore.java:287)
at org.apache.rocketmq.broker.BrokerController.initialize(BrokerController.java:754)
at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:224)
at org.apache.rocketmq.proxy.ProxyStartup.createBrokerController(ProxyStartup.java:212)
at org.apache.rocketmq.proxy.ProxyStartup.createMessagingProcessor(ProxyStartup.java:171)
at org.apache.rocketmq.proxy.ProxyStartup.main(ProxyStartup.java:79)
之前大家如果搭建过老版本的RocketMQ基本都遇到过,因为使用jdk版本高的原因,jdk1.8以上涉及到导包的问题,所以RocketMQ启动命令不兼容。
两个解决路径:
(1)使用jdk1.8 (不推荐,现在jdk都到多少版本了)
(2)修改broker启动命令,强行导包。
因为RocketMQ 5.0的bin/mqbroker启动命令指向的是runserver.sh,所以需要修改runserver.sh,在最后一行修改为以下内容。(看其他人的帖子,老版本的RocketMQ是runBroker.sh?我没安装过,大伙如果方便可以告诉我下是吗?)
文件runsever.sh
![rocketMQ5.0启动broker报错:module java.base does not export sun.nio.ch to unnamed module,Rocket 5.0 爬坑记,java,Powered by 金山文档](https://imgs.yssmx.com/Uploads/2023/08/653419-1.jpeg)
$JAVA ${JAVA_OPT} --add-exports=java.base/sun.nio.ch=ALL-UNNAMED $@文章来源:https://www.toymoban.com/news/detail-653419.html
标记橙色就是新增的。修改保存后,启动broker不再报错。文章来源地址https://www.toymoban.com/news/detail-653419.html
到了这里,关于rocketMQ5.0启动broker报错:module java.base does not export sun.nio.ch to unnamed module的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!