activemq日志抛出ReadOnlyBufferException
今天搭建一个MQ的环境,配置完启动起来后发现WEB界面无法访问,后台日志抛了一个Nio的Exception:
INFO | Initializing Spring FrameworkServlet 'dispatcher'
WARN | /java.nio.ReadOnlyBufferException
at java.nio.ByteBuffer.array(ByteBuffer.java:723)
at sun.nio.ch.IOUtil.prepareIOVec(IOUtil.java:101)
at sun.nio.ch.IOUtil.write(IOUtil.java:184)
at sun.nio.ch.SocketChannelImpl.write0(SocketChannelImpl.java:365)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:388)
at java.nio.channels.SocketChannel.write(SocketChannel.java:360)
at org.eclipse.jetty.io.nio.ChannelEndPoint.gatheringFlush(ChannelEndPoint.java:376)
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:335)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:336)
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:838)
at org.eclipse.jetty.http.AbstractGenerator.flush(AbstractGenerator.java:443)
at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:101)
at org.eclipse.jetty.server.AbstractHttpConnection$Output.flush(AbstractHttpConnection.java:1079)
at org.eclipse.jetty.server.AbstractHttpConnection$Output.sendContent(AbstractHttpConnection.java:1194)
at org.eclipse.jetty.server.handler.ResourceHandler.handle(ResourceHandler.java:487)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:532)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:367)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:989)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:609)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:619)
在经过几番测试后,定位到JDK版本的问题,MQ的版本5.9.0,默认JDK版本为JRockit的1.6.0_22.之后升级到了HotSpot的1.7.0_02才解决此问题。
具体原因还不清楚,估计是获取到请求数据后交给Jetty来解析时抛出的只读异常,让我一度认为是虚拟机的数据转发导致了数据异常。