Boa tarde!
Este problema já é conhecido, tentei as soluções descritas na documentação, as sugeridas pelo professor nas explicações e até a de um aluno mas não consegui resolver.
javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class br.com.jjp.modelo.Pedido! 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.
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:213)
at br.com.jjp.jms.TesteConsumidorTopicoComercial$1.onMessage(TesteConsumidorTopicoComercial.java:44)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1433)
at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: Forbidden class br.com.jjp.modelo.Pedido! 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.
at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.checkSecurity(ClassLoadingAwareObjectInputStream.java:115)
at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:56)
at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1995)
at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1862)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2169)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)
at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:211)
... 9 more
Tentei isto:
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*");
InitialContext context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");
((ActiveMQConnectionFactory) factory).setTrustAllPackages(true);
E esse:
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext();
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory)
context.lookup("ConnectionFactory");
factory.setTrustAllPackages(true);
mas nenhum resolveu.
Estou com Java 11 e activemq-all-5.16.1 e Eclipse 2021
Agradeço qualquer ajuda que possa me levar a solução.
Abs!