I create two Springboot servers and client applications exchanging using JMS and everything works fine on release 5.12.1 for activemq, but as soon as I upgrade to version 5.12.3 I get the following error
org.springframework.jms.support.converter.MessageConversionException: Could not convert JMS message; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class MyClass! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
I went to the URL that is provided, and I realized that my problem was with the new security in ActiveMQ release 5.12.2 , and I understand that I can fix it by specifying reliable packages, but I donโt know where to put this configuration in my SpringBoot project.
The only link I make to the JMS queue on my client and on my server is setting its URI in application.properties and @EnableJms on the JMS in my "main" class with @EnableJms , and here my configuration is on a separate broker:
@Configuration @ConfigurationProperties(prefix = "activemq") public class BrokerConfiguration { private String connectorURI = "tcp://0.0.0.0:10000"; private String kahaDBDataDir = "../../data/activemq"; public String getConnectorURI() { return connectorURI; } public void setConnectorURI(String connectorURI) { this.connectorURI = connectorURI; } public String getKahaDBDataDir() { return kahaDBDataDir; } public void setKahaDBDataDir(String kahaDBDataDir) { this.kahaDBDataDir = kahaDBDataDir; } @Bean(initMethod = "start", destroyMethod = "stop") public BrokerService broker() throws Exception { KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File(kahaDBDataDir)); final BrokerService broker = new BrokerService(); broker.addConnector(getConnectorURI()); broker.setPersistent(true); broker.setPersistenceAdapter(persistenceAdapter); broker.setShutdownHooks(Collections.<Runnable> singletonList(new SpringContextHook())); broker.setUseJmx(false); final ManagementContext managementContext = new ManagementContext(); managementContext.setCreateConnector(true); broker.setManagementContext(managementContext); return broker; } }
So, I would like to know where I should specify trusted packages.
Thanks:)
java spring-boot activemq
Antoineb
source share