ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

MMA_EDFX
This post was updated on .
Hello,
        I am getting the below error while posting the message to jms queue.
I have gone through the link http://activemq.apache.org/objectmessage.html provided in the error message. But I could not resolve the issue.

I am using TomEE 7.0 server

1) I have added this in Tomee 7.0's catalina.bat file.

set ALL_PACKAGE="*"
set JAVA_OPTS = %JAVA_OPTS% -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=%ALL_PACKAGE%

2)This is my activemq.xml file.

   
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.13.3.xsd">
       
        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                <property name="properties">
                        <props>
                                <prop key="data.dir">data</prop>
                        </props>
                </property>
        </bean>

        <broker xmlns="http://activemq.apache.org/schema/core" useJmx="true"
                brokerName="localhost" useShutdownHook="false" persistent="true"
                start="true" schedulerSupport="false" enableStatistics="false"
                offlineDurableSubscriberTimeout="259200000"
                offlineDurableSubscriberTaskSchedule="3600000">

                <destinations>
                        <queue physicalName="entryPointSiretailQueue" />
                </destinations>


                <persistenceAdapter>
                        <kahaDB directory="${data.dir}/activemq-data/kaha"
                                indexCacheSize="20000" ignoreMissingJournalfiles="true"
                                checkForCorruptJournalFiles="true" checksumJournalFiles="true" />
                </persistenceAdapter>

                <systemUsage>
                        <systemUsage>
                                <memoryUsage>
                                        <memoryUsage limit="64 mb" />
                                </memoryUsage>
                                <storeUsage>
                                        <storeUsage limit="10 gb" />
                                </storeUsage>
                        </systemUsage>
                </systemUsage>

               
                <transportConnectors>
                       
                        <transportConnector name="vm"
                                uri="vm://localhost:16013/localhost?waitForStart=30000&amp;async=true" />
                </transportConnectors>
        </broker>
</beans>

3)This is the error I am getting while posting message to the queue.

javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class com.edifixio.osrd.service.middleoffice.MiddleOfficeMessage! 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:208)
        at com.senoble.siretail.service.entrypointsiretail.EntryPointSiretailServiceImpl.dealWithMessageUniqueDelivery(EntryPointSiretailServiceImpl.java:80)
        ... 31 more
Caused by: java.lang.ClassNotFoundException: Forbidden class com.edifixio.osrd.service.middleoffice.MiddleOfficeMessage! 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:112)
        at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:57)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
        at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:206)
        ... 32 more
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

Hassen Bennour
Hello,

This config need to be done on the clients side and on the activemq side ,
the serialized classes must be on the classpath of the producer and
consumer, i think on the broker side too to unmarshal received object no ?
You need to check these conditions.

You use TomEE for deploying the client ?

Please verify your config as said in the link you provided, this for the
broker side and not the better for client :

If you need to exchange object messages, you need to add packages your
applications are using. You can do that with by using
org.apache.activemq.SERIALIZABLE_PACKAGES system property of the broker.
You can add this system property to ACTIVEMQ_OPTS variable...

For client side it's better with setTrustedPackages() method as mentioned
in the link.

Don't forget the security constraints.

Hassen.

Le 21 juin 2016 18:16, "MMA_EDFX" <[hidden email]> a écrit :
>
> Hello,
>         I am getting the below error while posting the message to jms
queue.

> I have gone through the link http://activemq.apache.org/objectmessage.html
> provided in the error message. But I could not resolve the issue.
>
> I am using TomEE 7.0 server
>
> 1) I have added this in Tomee 7.0's catalina.bat file.
>
> set ALL_PACKAGE="*"
> set JAVA_OPTS = %JAVA_OPTS%
> "-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=%ALL_PACKAGE%"
>
> 2)This is my activemq.xml file.
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:amq="http://activemq.apache.org/schema/core"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://activemq.apache.org/schema/core
> http://activemq.apache.org/schema/core/activemq-core-5.13.3.xsd">
>
> <bean
>
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

>
> <property name="properties">
> <props>
> <prop key="data.dir">data</prop>
> </props>
> </property>
> </bean>
>
> <broker xmlns="http://activemq.apache.org/schema/core" useJmx="true"
> brokerName="localhost" useShutdownHook="false" persistent="true"
> start="true" schedulerSupport="false" enableStatistics="false"
> offlineDurableSubscriberTimeout="259200000"
> offlineDurableSubscriberTaskSchedule="3600000">
>
>  <destinations>
>      <queue physicalName="entryPointSiretailQueue"/>
>     </destinations>
>
>
> <persistenceAdapter>
> <kahaDB directory="${data.dir}/activemq-data/kaha" indexCacheSize="20000"
> ignoreMissingJournalfiles="true" checkForCorruptJournalFiles="true"
> checksumJournalFiles="true"/>
> </persistenceAdapter>
>
> <systemUsage>
>    <systemUsage>
>     <memoryUsage>
>       <memoryUsage limit="64 mb" />
>     </memoryUsage>
>     <storeUsage>
>       <storeUsage limit="10 gb" />
>     </storeUsage>
>   </systemUsage>
> </systemUsage>
>
>
> <transportConnectors>
>
> <transportConnector name="vm"
> uri="vm://localhost:16013/localhost?waitForStart=30000&amp;async=true"/>
>
>
> </transportConnectors>
>
> </broker>
> </beans>
>
> 3)This is the error I am getting while posting message to the queue.
>
> javax.jms.JMSException: Failed to build body from content. Serializable
> class not available to broker. Reason: java.lang.ClassNotFoundException:
> Forbidden class
com.edifixio.osrd.service.middleoffice.MiddleOfficeMessage!
> 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:208)
>         at
>
com.senoble.siretail.service.entrypointsiretail.EntryPointSiretailServiceImpl.dealWithMessageUniqueDelivery(EntryPointSiretailServiceImpl.java:80)
>         ... 31 more
> Caused by: java.lang.ClassNotFoundException: Forbidden class
> com.edifixio.osrd.service.middleoffice.MiddleOfficeMessage! 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:112)
>         at
>
org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:57)
>         at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
>         at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
>         at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>         at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
>         at
>
org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:206)
>         ... 32 more
>
>
>
> --
> View this message in context:
http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-3-Class-is-not-trusted-to-be-serialized-as-ObjectMessage-payload-tp4713199.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

MMA_EDFX
Hello,
        Thanks for the reply. For me with the same configuration it works fine in TomEE 1.7.2 (ActiveMQ 5.10.0). TomEE has activemq-client-5.X.Y,activemq-broker-5.X.Y jars in its lib. So how and where (which file) can I configure the Serializable package stuff?

This is my JMS config defined in tomee.xml file:

<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig  = xbean:activemq.xml
        ServerUrl = vm://localhost:61616
</Resource>
       
<Resource id="JMSConnectionFactory" type="javax.jms.QueueConnectionFactory">
                connectionMaxIdleTime = 15 Minutes
                connectionMaxWaitTime = 5 seconds
                ResourceAdapter = MyJmsResourceAdapter
                poolMaxSize = 10
                poolMinSize = 0
                transactionSupport = xa
</Resource>
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

Hassen Bennour
Hello,

Via system property in catalina.bat or in the
<tomee-home>/conf/system.properties file like mentioned here
http://tomee.apache.org/activemqresourceadapter-config.html  must be ok for
your use normally,  did you tried with ActiveMQConnectionSupport like
mentioned here https://issues.apache.org/jira/browse/AMQ-6312

Honestly i don't used resources adapter since years and i don't have my
laptop to check , hope this help.

Hassen.
Hello,
        Thanks for the reply. For me with the same configuration it works
fine in TomEE 1.7.2 (ActiveMQ 5.10.0). TomEE has
activemq-client-5.X.Y,activemq-broker-5.X.Y jars in its lib. So how and
where (which file) can I configure the Serializable package stuff?

This is my JMS config defined in tomee.xml file:

<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig  = xbean:activemq.xml
        ServerUrl = vm://localhost:61616
</Resource>

<Resource id="JMSConnectionFactory" type="javax.jms.QueueConnectionFactory">
                connectionMaxIdleTime = 15 Minutes
                connectionMaxWaitTime = 5 seconds
                ResourceAdapter = MyJmsResourceAdapter
                poolMaxSize = 10
                poolMinSize = 0
                transactionSupport = xa
</Resource>



--
View this message in context:
http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-3-Class-is-not-trusted-to-be-serialized-as-ObjectMessage-payload-tp4713199p4713209.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

Hassen Bennour
Hello,

in catalina logs did you have this log ?*
sun.reflect.NativeMethodAccessorImpl.invoke
Command line argument: -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=* *
because your example not work for me, but this one is ok
*set ALL_PACKAGE_OPTS="-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"*
*set "JAVA_OPTS=%JAVA_OPTS% %ALL_PACKAGE_OPTS%"*

i checked the code and if system property is set correctly this have to
work fine.



Kind regards.

*BENNOUR HASSEN*

*SOA **Architect **/ **Java **Software Engineer*

2016-06-21 23:09 GMT+02:00 Hassen Bennour <[hidden email]>:

> Hello,
>
> Via system property in catalina.bat or in the
> <tomee-home>/conf/system.properties file like mentioned here
> http://tomee.apache.org/activemqresourceadapter-config.html  must be ok
> for your use normally,  did you tried with ActiveMQConnectionSupport like
> mentioned here https://issues.apache.org/jira/browse/AMQ-6312
>
> Honestly i don't used resources adapter since years and i don't have my
> laptop to check , hope this help.
>
> Hassen.
> Hello,
>         Thanks for the reply. For me with the same configuration it works
> fine in TomEE 1.7.2 (ActiveMQ 5.10.0). TomEE has
> activemq-client-5.X.Y,activemq-broker-5.X.Y jars in its lib. So how and
> where (which file) can I configure the Serializable package stuff?
>
> This is my JMS config defined in tomee.xml file:
>
> <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
>         BrokerXmlConfig  = xbean:activemq.xml
>         ServerUrl = vm://localhost:61616
> </Resource>
>
> <Resource id="JMSConnectionFactory"
> type="javax.jms.QueueConnectionFactory">
>                 connectionMaxIdleTime = 15 Minutes
>                 connectionMaxWaitTime = 5 seconds
>                 ResourceAdapter = MyJmsResourceAdapter
>                 poolMaxSize = 10
>                 poolMinSize = 0
>                 transactionSupport = xa
> </Resource>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-3-Class-is-not-trusted-to-be-serialized-as-ObjectMessage-payload-tp4713199p4713209.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

MMA_EDFX
Thanks Hassan. I was adding the ALL_PACKAGE_OPTS in wrong place. So it was not come in the log file.
Thanks again

I added after the line

rem Add OpenEJB javaagent

set ALL_PACKAGE_OPTS="-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"
set JAVA_OPTS=%JAVA_OPTS% %ALL_PACKAGE_OPTS%

Now it looks to be working.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ 5.13.3: Class is not trusted to be serialized as ObjectMessage payload

Hassen Bennour
happy for you!



Kind regards.

*BENNOUR HASSEN*

*SOA **Architect **/ **Java **Software Engineer*

2016-06-22 13:34 GMT+02:00 MMA_EDFX <[hidden email]>:

> Thanks Hassan. I was adding the ALL_PACKAGE_OPTS in wrong place. So it was
> not come in the log file.
> Thanks again
>
> I added after the line
>
> rem Add OpenEJB javaagent
>
> set ALL_PACKAGE_OPTS="-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"
> set JAVA_OPTS=%JAVA_OPTS% %ALL_PACKAGE_OPTS%
>
> Now it looks to be working.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-3-Class-is-not-trusted-to-be-serialized-as-ObjectMessage-payload-tp4713199p4713246.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>