https://issues.apache.org/jira/browse/AMQCPP-587

Clone the exception being passed to XAException as the cause exception
to avoid a seg fault due to trying to delete a pointer to a reference.
(cherry picked from commit b61e95c47970f9ab946928674d9da35752f29413)
diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp
index dbd81b3..06b7175 100644
--- a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp
+++ b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp
@@ -747,7 +747,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 XAException ActiveMQTransactionContext::toXAException(decaf::lang::Exception& ex) {
     CMSException cmsEx = CMSExceptionSupport::create(ex);
-    XAException xae(ex.getMessage(), &cmsEx);
+    XAException xae(ex.getMessage(), cmsEx.clone());
     xae.setErrorCode(XAException::XAER_RMFAIL);
     return xae;
 }