Java 使用Wildfly 8的GarbageCollectionNotificationInfo会导致NoClassDefFoundError
我正在尝试使用GarbageCollectionNotificationInfo订阅GC通知。通知可以工作,但当我尝试在Wildfly 8.2中使用此机制时,我得到一个Java 使用Wildfly 8的GarbageCollectionNotificationInfo会导致NoClassDefFoundError,java,jboss,wildfly,Java,Jboss,Wildfly,我正在尝试使用GarbageCollectionNotificationInfo订阅GC通知。通知可以工作,但当我尝试在Wildfly 8.2中使用此机制时,我得到一个java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: com/sun/management/GarbageCollectionNotificationInfo 2017-02-06 08:40:09,156 ERROR [stderr] (Service T
java.lang.NoClassDefFoundError
:
java.lang.NoClassDefFoundError: com/sun/management/GarbageCollectionNotificationInfo
2017-02-06 08:40:09,156 ERROR [stderr] (Service Thread) at com.vonage.metrics.GCNotificationListener.handleNotification(GCNotificationListener.java:28)
2017-02-06 08:40:09,156 ERROR [stderr] (Service Thread) at sun.management.NotificationEmitterSupport.sendNotification(NotificationEmitterSupport.java:156)
2017-02-06 08:40:09,157 ERROR [stderr] (Service Thread) at sun.management.GarbageCollectorImpl.createGCNotification(GarbageCollectorImpl.java:147)
我发现在某些情况下,您需要在Jboss/Wildfly中包含依赖项:
我是否需要以某种方式包含com.sun.*软件包?我最近遇到了同样的问题,只有WildFly
10.1.0.Final
解决方案是在jboss部署结构.xml
中使用类似的内容显式地包括com.sun.management
类:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<system>
<paths>
<path name="com/sun/management"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>