在 Karaf 中添加 activemq 可信包

Adding activemq trusted package in Karaf

我正在尝试将我的包添加为 activemq 中的(反)序列化可信包。

我正在使用 Mongo 3.0.1,所以 BsonArray.parse(...) 不是一个选项。

我试过 System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*"); 但它被忽略了。从 this 开始,在 spring/camel 中设置它会覆盖系统属性。

This configuration will override system properties if they are set.

将同一 link 中的以下内容复制粘贴到我的 blueprint.xml 中导致了一堆 "amq-broker" 错误,需要从头开始重新安装所有内容才能修复,我不敢尝试再次获取错误消息。

<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616"/>
    <property name="trustAllPackages" value="true"/>
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="connectionFactory"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="jmsConfig"/>
</bean>

那么,在Karaf/ServiceMix中,将可信包添加到activemq的正确方法是什么?

相关question,但系统属性对我不起作用,而且我不知道 ActiveMQ 配置在 Karaf 中的什么位置。

我想通了我的问题。 System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*"); 在我的激活器中不起作用的原因是因为 ActiveMQ 只在启动时读取 org.apache.activemq.SERIALIZABLE_PACKAGES,并且 ActiveMQ 在我的 Karaf 包之前启动。

我不确定如何从我的激活器重新启动 ActiveMQ 以强制它在 运行 时获取更改,但您可以在 <Karaf-home>/etc/system.properties 中手动设置 org.apache.activemq.SERIALIZABLE_PACKAGES=*。这将在 ActiveMQ 启动之前为您设置 属性,以便 ActiveMQ 接收您的配置。请注意,更改 system.properties 文件后,您需要重新启动 Karaf 才能使更改生效。