当“客户端”WildFly-8.2实例连接到由不同的WidlFly-8.2实例启动的HornetQ服务器时,服务器端会反复抛出ClassNotFoundException并将带有堆栈跟踪的WARN消息写入实例日志:
2015-07-15 18:43:41,223 WARNING [io.netty.channel.ChannelOutboundBuffer] (Thread-1 (hornetq-netty-threads--170443211)) Failed to release a message.: java.lang.NoClassDefFoundError: sun.misc.Unsafe
at io.netty.util.internal.PlatformDependent.freeDirectBuffer(PlatformDependent.java:234) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.buffer.UnpooledDirectByteBuf.freeDirect(UnpooledDirectByteBuf.java:112) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.buffer.UnpooledDirectByteBuf.deallocate(UnpooledDirectByteBuf.java:596) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:120) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:68) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.ChannelOutboundBuffer.safeRelease(ChannelOutboundBuffer.java:509) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:268) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.nio.AbstractNioByteChannel.doWrite(AbstractNioByteChannel.java:216) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:231) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:682) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:283) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:651) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelPipeline$HeadHandler.flush(DefaultChannelPipeline.java:1038) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:675) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelHandlerContext.flush(DefaultChannelHandlerContext.java:656) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:675) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelHandlerContext.access$1600(DefaultChannelHandlerContext.java:29) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:908) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [netty-all-4.0.15.Final.jar:4.0.15.Final]
at java.lang.Thread.run(Thread.java:853) [vm.jar:1.7.0]
Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe from [Module "io.netty:main" from local module loader @7be7a114 (finder: local module finder @4861e893 (roots: /norma/wildfly/modules,/norma/wildfly/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
... 23 more
两个WildFly实例之间的连接仍然有效,但日志文件很快达到服务器磁盘配额的100%,然后服务器应用程序停止。
我的实例配置HornetQ的消息传递部分,它应该以下列方式接受外部连接:
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<persistence-enabled>true</persistence-enabled>
<security-enabled>false</security-enabled>
<journal-file-size>102400</journal-file-size>
<journal-min-files>2</journal-min-files>
<connectors>
<http-connector name="http-connector" socket-binding="http">
<param key="http-upgrade-endpoint" value="http-acceptor"/>
</http-connector>
<http-connector name="http-connector-throughput" socket-binding="http">
<param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
<param key="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<acceptors>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" name="http-acceptor-throughput">
<param key="batch-delay" value="50"/>
<param key="direct-deliver" value="false"/>
</http-acceptor>
<netty-acceptor name="netty-norma" socket-binding="norma-jms-broker"/>
<netty-acceptor name="netty-norma-throughput" socket-binding="norma-jms-broker-throughput">
<param key="batch-delay" value="50"/>
</netty-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createDurableQueue" roles="guest"/>
<permission type="deleteDurableQueue" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
<address-settings>
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<max-size-bytes>10485760</max-size-bytes>
<page-size-bytes>2097152</page-size-bytes>
<address-full-policy>PAGE</address-full-policy>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
</address-setting>
</address-settings>
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
</connection-factory>
<connection-factory name="RemoteConnectionFactory">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
</connection-factory>
<connection-factory name="DurableSubscribersConnectionFactory">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:/DurableSubscribersConnectionFactory"/>
<entry name="java:jboss/exported/DurableSubscribersConnectionFactory"/>
</entries>
</connection-factory>
<pooled-connection-factory name="hornetq-ra">
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/JmsXA"/>
<entry name="java:jboss/DefaultJMSConnectionFactory"/>
</entries>
</pooled-connection-factory>
</jms-connection-factories>
<jms-destinations>
<jms-topic name="SunsetEventsTopic">
<entry name="jms/topic/SunsetEventsTopic"/>
<entry name="java:jboss/exported/jms/topic/SunsetEventsTopic"/>
</jms-topic>
</jms-destinations>
</hornetq-server>
</subsystem>
和
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<!-- CONNECT TO IBM HORNETQ BROKER -->
<socket-binding name="norma-jms-broker" port="${norma.broker.port:5445}"/>
<socket-binding name="norma-jms-broker-throughput" port="${norma.broker.port:5445}"/>
</socket-binding-group>
如何解决此问题?
答案 0 :(得分:1)
对于此例外
Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe from [Module "io.netty:main" from local module loader @7be7a114 (finder: local module finder @4861e893 (roots: /norma/wildfly/modules,/norma/wildfly/modules/system/layers/base))]
在%jboss_home%/modules/system/layers/base/io/netty/main/module.xml
Module.xml将如下所示
<module xmlns="urn:jboss:module:1.3" name="io.netty">
<resources>
<resource-root path="netty-all-4.0.15.Final.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="sun.jdk"/>
<module name="org.javassist" optional="true"/>
</dependencies>
</module>
答案 1 :(得分:1)
我遵循了Happy的建议并通过配置netty模块解决了这个问题:
<module xmlns="urn:jboss:module:1.3" name="io.netty">
<resources>
<resource-root path="netty-all-4.0.15.Final.jar"/>
</resources>
<dependencies>
<module name="sun.jdk" export="true" >
<imports>
<include path="sun/misc/Unsafe" />
</imports>
</module>
</dependencies>
</module>
答案 2 :(得分:0)
运行配置 vm参数。加 &#34; -Dio.netty.noUnsafe =真&#34;