使用Wildfly 8的GarbageCollectionNotificationInfo导致NoClassDefFoundError

时间:2017-02-06 11:36:28

标签: 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 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中包含依赖项:https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly

我是否需要以某种方式包含com.sun。*包?

1 个答案:

答案 0 :(得分:1)

我最近遇到了同样的问题,只有WildFly 10.1.0.Final

解决方案是在com.sun.management中使用类似的内容明确包含jboss-deployment-structure.xml类:

<?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>