Java Code Examples for javax.jms.JMSException#initCause()
The following examples show how to use
javax.jms.JMSException#initCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMSExceptionSupport.java From pooled-jms with Apache License 2.0 | 6 votes |
/** * Creates or passes through a JMSException to be thrown to the client. * * In the event that the exception passed to this method is already a * JMSException it is passed through unmodified, otherwise a new JMSException * is created with the given message and the cause is set to the given * cause Throwable instance. * * @param message * The message value to set when a new JMSException is created. * @param cause * The exception that caused this error state. * * @return a JMSException instance. */ public static JMSException create(String message, Throwable cause) { if (cause instanceof JMSException) { return (JMSException) cause; } if (cause.getCause() instanceof JMSException) { return (JMSException) cause.getCause(); } if (message == null || message.isEmpty()) { message = cause.getMessage(); if (message == null || message.isEmpty()) { message = cause.toString(); } } JMSException exception = new JMSException(message); if (cause instanceof Exception) { exception.setLinkedException((Exception) cause); } exception.initCause(cause); return exception; }
Example 2
Source File: JMS11WorkerThread.java From perf-harness with MIT License | 6 votes |
/** * Overloaded method to cross-link JDK 1.4 initCause and JMS 1.1 * linkedException if it has not already been done by the JMS vendor * implementation. * * @param je */ protected void handleException(JMSException je) { // Cross-link JDK 1.4 initCause and JMS 1.1 linkedexception if it has // not already been done by the JMS vendor implementation. if ( endTime==0 ) { endTime = System.currentTimeMillis(); } Exception le = je.getLinkedException(); Throwable t = je.getCause(); if (null==t && null!=le && t != le) { je.initCause(le); } handleException((Exception) je); }
Example 3
Source File: ActiveMQRAManagedConnection.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void checkTransactionActive() throws JMSException { // don't bother looking at the transaction if there's an active XID if (!inManagedTx && tm != null) { try { Transaction tx = tm.getTransaction(); if (tx != null) { int status = tx.getStatus(); // Only allow states that will actually succeed if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING) { throw new javax.jms.IllegalStateException("Transaction " + tx + " not active"); } } } catch (SystemException e) { JMSException jmsE = new javax.jms.IllegalStateException("Unexpected exception on the Transaction ManagerTransaction"); jmsE.initCause(e); throw jmsE; } } }
Example 4
Source File: ActiveMQRASession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Get the XA resource and ensure that it is open * * @return The XA Resource * @throws JMSException Thrown if an error occurs * @throws IllegalStateException The session is closed */ XAResource getXAResourceInternal() throws JMSException { if (mc == null) { throw new IllegalStateException("The session is closed"); } try { XAResource xares = mc.getXAResource(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getXAResourceInternal " + xares + " for " + this); } return xares; } catch (ResourceException e) { JMSException jmse = new JMSException("Unable to get XA Resource"); jmse.initCause(e); throw jmse; } }
Example 5
Source File: JmsExceptionSupport.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Creates or passes through a JMSException to be thrown to the client. * * In the event that the exception passed to this method is already a * JMSException it is passed through unmodified, otherwise a new JMSException * is created with the given message and the cause is set to the given * cause Throwable instance. * * @param message * The message value to set when a new JMSException is created. * @param cause * The exception that caused this error state. * * @return a JMSException instance. */ public static JMSException create(String message, Throwable cause) { if (cause instanceof JMSException) { return (JMSException) cause; } if (cause.getCause() instanceof JMSException) { return (JMSException) cause.getCause(); } else if (cause instanceof ProviderException) { return ((ProviderException) cause).toJMSException(); } if (message == null || message.isEmpty()) { message = cause.getMessage(); if (message == null || message.isEmpty()) { message = cause.toString(); } } JMSException exception = new JMSException(message); if (cause instanceof Exception) { exception.setLinkedException((Exception) cause); } exception.initCause(cause); return exception; }
Example 6
Source File: ActiveMQObjectMessage.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void setObject(final Serializable object) throws JMSException { checkWrite(); if (object != null) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); oos.flush(); data = baos.toByteArray(); } catch (Exception e) { JMSException je = new JMSException("Failed to serialize object"); je.setLinkedException(e); je.initCause(e); throw je; } } }
Example 7
Source File: ActiveMQConnection.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void setClientID(final String clientID) throws JMSException { checkClosed(); if (this.clientID != null) { throw new IllegalStateException("Client id has already been set"); } if (!justCreated) { throw new IllegalStateException("setClientID can only be called directly after the connection is created"); } try { validateClientID(initialSession, clientID); this.clientID = clientID; this.addSessionMetaData(initialSession); } catch (ActiveMQException e) { JMSException ex = new JMSException("Internal error setting metadata jms-client-id"); ex.setLinkedException(e); ex.initCause(e); throw ex; } justCreated = false; }
Example 8
Source File: JMS20WorkerThread.java From perf-harness with MIT License | 5 votes |
/** * Overloaded method to cross-link JDK 1.4 initCause and JMS 1.1 * linkedException if it has not already been done by the JMS vendor * implementation. * * @param je */ protected void handleException(JMSException je) { //If thread not already stopped, set endTime if (endTime == 0) { endTime = System.currentTimeMillis(); } Exception le = je.getLinkedException(); Throwable t = je.getCause(); if ((null == t) && (null != le) && (t != le)) { je.initCause(le); } handleException((Exception) je); }
Example 9
Source File: AmazonSQSMessagingClientWrapper.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
/** * Sets SQS endpoint and wraps IllegalArgumentException. * Deprecated. Instead of manipulating settings of existing AmazonSQS client, provide correct configuration when creating it through SQSConnectionFactory constructors. * * @param endpoint * The endpoint (ex: "sqs.us-east-1.amazonaws.com") of the region * specific AWS endpoint this client will communicate with. * @throws JMSException */ @Deprecated public void setEndpoint(String endpoint) throws JMSException { try { amazonSQSClient.setEndpoint(endpoint); } catch (IllegalArgumentException ase) { JMSException jmsException = new JMSException(ase.getMessage()); throw (JMSException) jmsException.initCause(ase); } }
Example 10
Source File: ActiveMQBytesMessage.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void clearBody() throws JMSException { super.clearBody(); try { getBuffer().clear(); } catch (RuntimeException e) { JMSException e2 = new JMSException(e.getMessage()); e2.initCause(e); throw e2; } }
Example 11
Source File: ActiveMQBytesMessage.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void writeUTF(final String value) throws JMSException { checkWrite(); try { bytesWriteUTF(message.getBodyBuffer(), value); } catch (Exception e) { JMSException je = new JMSException("Failed to write UTF"); je.setLinkedException(e); je.initCause(e); throw je; } }
Example 12
Source File: ActiveMQConnection.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public synchronized void connectionFailed(final ActiveMQException me, boolean failedOver) { if (me == null) { return; } ActiveMQConnection conn = connectionRef.get(); if (conn != null) { try { final ExceptionListener exceptionListener = conn.getExceptionListener(); if (exceptionListener != null) { final JMSException je = new JMSException(me.toString(), failedOver ? EXCEPTION_FAILOVER : EXCEPTION_DISCONNECT); je.initCause(me); new Thread(new Runnable() { @Override public void run() { exceptionListener.onException(je); } }).start(); } } catch (JMSException e) { if (!conn.closed) { ActiveMQJMSClientLogger.LOGGER.errorCallingExcListener(e); } } } }
Example 13
Source File: JMSExceptionHelper.java From activemq-artemis with Apache License 2.0 | 5 votes |
public static JMSException convertFromActiveMQException(final ActiveMQInterruptedException me) { JMSException je = new javax.jms.IllegalStateException(me.getMessage()); je.setStackTrace(me.getStackTrace()); je.initCause(me); return je; }
Example 14
Source File: ActiveMQMessage.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException { try { MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID); } catch (ActiveMQException e) { JMSException ex = new JMSException(e.getMessage()); ex.initCause(e); throw ex; } }
Example 15
Source File: ProviderException.java From qpid-jms with Apache License 2.0 | 4 votes |
public JMSException toJMSException() { final JMSException jmsEx = new JMSException(getMessage()); jmsEx.initCause(this); jmsEx.setLinkedException(this); return jmsEx; }
Example 16
Source File: SQSMessage.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 4 votes |
protected static JMSException convertExceptionToJMSException(Exception e) { JMSException ex = new JMSException(e.getMessage()); ex.initCause(e); return ex; }
Example 17
Source File: JMSManagementHelper.java From activemq-artemis with Apache License 2.0 | 3 votes |
private static JMSException convertFromException(final Exception e) { JMSException jmse = new JMSException(e.getMessage()); jmse.initCause(e); return jmse; }
Example 18
Source File: AmazonSQSMessagingClientWrapper.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 3 votes |
/** * Sets SQS region and wraps <code>IllegalArgumentException</code>. * Deprecated. Instead of manipulating settings of existing AmazonSQS client, provide correct configuration when creating it through SQSConnectionFactory constructors. * * @param region * The region this client will communicate with. See * {@link Region#getRegion(com.amazonaws.regions.Regions)} for * accessing a given region. * @throws JMSException */ @Deprecated public void setRegion(Region region) throws JMSException { try { amazonSQSClient.setRegion(region); } catch (IllegalArgumentException ase) { JMSException jmsException = new JMSException(ase.getMessage()); throw (JMSException) jmsException.initCause(ase); } }