【问题标题】:NoValueFactoryException when using Zeroc Ice - Sliced vs. compact format?使用 Zeroc Ice 时出现 NoValueFactoryException - 切片与紧凑格式?
【发布时间】:2019-02-04 09:53:11
【问题描述】:

我正在尝试在 OSGi 上下文中使用 Ice 客户端。在非 OSGi 环境中运行服务器和最小示例客户端可以正常工作。对于 OSGi 环境中的客户端,我得到以下异常:

com.zeroc.Ice.NoValueFactoryException
    reason = "no value factory found and compact format prevents slicing (the sender should use the sliced format instead)"
    type = "::MyModule::Knowledge::CMKnowledge"

但是,我不能 100% 确定 OSGi 运行时是否在这里有所作为。 Slice 文件如下所示:

module MyModule{
    module Knowledge{
        class KnowledgePart{
            string value;
        }

        class FMKnowledge extends KnowledgePart{}
        class CMKnowledge extends KnowledgePart{}

        interface IKnowledge{
            void sendKnowledge(KnowledgePart knowledge);
            FMKnowledge getFMKnowledge();
            CMKnowledge getCMKnowledge();
        }
    }
}

在这种情况下,这个异常是什么意思,我该如何解决?我已经尝试设置 ["format:sliced"] 而不是隐式使用的紧凑格式。

【问题讨论】:

    标签: ice


    【解决方案1】:

    这个错误意味着 Ice run-time 尝试加载 MyModule.Knowledge.CMKnowledge 类但它没有这样做。您必须确保应用程序使用的类加载器可以加载MyModule.Knowledge.CMKnowledgeclass。

    另见https://doc.zeroc.com/ice/3.7/language-mappings/java-mapping/custom-class-loaders

    【讨论】:

    • 非常感谢!所以这是一个 OSGi 类加载器问题。我这样修复它: com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); initData.classLoader = bundleContext.getBundle().adapt(BundleWiring.class).getClassLoader();通讯器 = com.zeroc.Ice.Util.initialize(initData);
    猜你喜欢
    • 2020-08-08
    • 1970-01-01
    • 1970-01-01
    • 2010-11-30
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 2017-11-16
    • 1970-01-01
    相关资源
    最近更新 更多