Wildfly 18 - drools 7.39.0-Final:部署应用程序并获取 java.lang.NoClassDefFoundError:无法初始化类

时间:2021-01-29 21:29:43

标签: wildfly drools kie

一直在尝试将应用程序迁移到 WF 18.0 和drools 7.39.0-Final。 Drools 7.39.0-Final 是 WF18 的最后一个版本。

我们的一个应用程序使用了 drools/kie。

我在尝试部署时遇到如下错误。

<块引用>

"jboss.deployment.subunit.\"policy-ear.ear\".\"policy-beans.jar\".component.CepRuleEngineHolder.START" => "java.lang.IllegalStateException: WFLYEE0042: 构建组件实例失败 引起:java.lang.IllegalStateException:WFLYEE0042:构建组件实例失败 引起:javax.ejb.EJBException:WFLYEJB0442:意外错误 引起:java.lang.NoClassDefFoundError:无法初始化类org.drools.dynamic.DynamicServiceRegistrySupplier$LazyHolder"

通过搜索我发现这可能是由静态内容/构造函数失败引起的。 所以我下载了源代码,并作为一个实验改变了如下内容。这修复了它。 下面的这个例子展示了我为 KieServices 类所做的事情。

请注意,上面的错误是针对 DynamicServiceRegistrySupplier 类的,我尝试将更改应用于该类,但它是一个巨大的构建并且存在一些其他问题。在我追逐之前,我想问一下是否有更好的方法来做到这一点?看来我根本不需要这样做,这是 WF18 最新发布的流口水。

对于 KieServices,我改变了这个:

/**
 * A Factory for this KieServices
 */
class Factory {

    static class LazyHolder {
        private static KieServices INSTANCE = ServiceRegistry.getInstance().get(KieServices.class);
    }

    /**
     * Returns a reference to the KieServices singleton
     */
    public static KieServices get() {
        return LazyHolder.INSTANCE;
    }
}

到:

/**
 * A Factory for this KieServices
 */
class Factory {
    static private KieServices instance = null;
    public static class LazyHolder {
        public LazyHolder() {
        }
    }

    /**
     * Returns a reference to the KieServices singleton
     */
    public static KieServices get() {
        if ( instance == null) {
        instance =  ServiceRegistry.getInstance().get(KieServices.class);
        }
        return instance;
    }
}

0 个答案:

没有答案