0

I am doing a Publish - Subscribe using external ActiveMQ (5.15.10). My application is deployed on TomEE 8.0.1 server and ActiveMQ configurations are done in tomee.xml.

I am able publish the message successfully but while receiving messages am facing issues. In onMessage method I need to process a pojo and I get below error

"This class is not trusted to be serialized as ObjectMessage payload"

I use EclipseLink JPA in my application and I need to send the pojo that I receive in onMessage method to my @Stateless bean (here UserService) to process it further. So, UserService is injected with @EJB annotation in my MDBSubscriber class below.

@MessageDriven(
        activationConfig = { 
            @ActivationConfigProperty(
                    propertyName = "destinationType", 
                    propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty( 
                    propertyName = "destination", 
                    propertyValue = "userQueue")
            
        }
    )

public class MDBSubscriber implements MessageListener {
    
    @EJB
    UserService uService; 
    
    public void onMessage(Message msg) {    
    
        if(msg instanceof ObjectMessage) {
            ObjectMessage objMsg = (ObjectMessage) msg;
            UserForm uForm=  (UserForm) objMsg.getObject();
            ----
            ----
            uService.process(uForm);
        }
     }
}

When I read through ActiveMQ docs, it says setTrustAllPackages=true can be set on ActiveMQConnectionFactory object but since am using @MessageDriven Bean I don't have ActiveMQConnectionFactory object in my class defined above.

So, my problem is where or how do we define setTrustAllPackages=true in @MessageDriven Bean?

I am stuck with this problem since more than 10 days and could not find a solution. Can someone help me here ?

Anu
  • 1
  • 3

1 Answers1

0

You can configure this via a system property as well which avoids the trustAllPackages connection factory option. There is documentation for this already on the ActiveMQ site.

In case you want to shortcut this mechanism, you can allow all packages to be trusted by using * wildcard, like

-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*
Tim Bish
  • 17,475
  • 4
  • 32
  • 42