Search in sources :

Example 1 with ResourceException

use of javax.resource.ResourceException in project wildfly by wildfly.

the class EJBUtilities method createActivationSpecs.

public ActivationSpec createActivationSpecs(final String resourceAdapterName, final Class<?> messageListenerInterface, final Properties activationConfigProperties, final ClassLoader classLoader) {
    try {
        // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the
        // ra name
        final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName);
        if (raIdentifier == null) {
            throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName);
        }
        final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository();
        if (resourceAdapterRepository == null) {
            throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable();
        }
        // now get the message listeners for this specific ra identifier
        final List<MessageListener> messageListeners = resourceAdapterRepository.getMessageListeners(raIdentifier);
        if (messageListeners == null || messageListeners.isEmpty()) {
            throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
        }
        MessageListener requiredMessageListener = null;
        // now find the expected message listener from the list of message listeners for this resource adapter
        for (final MessageListener messageListener : messageListeners) {
            if (messageListenerInterface.equals(messageListener.getType())) {
                requiredMessageListener = messageListener;
                break;
            }
        }
        if (requiredMessageListener == null) {
            throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
        }
        // found the message listener, now finally create the activation spec
        final Activation activation = requiredMessageListener.getActivation();
        // filter out the activation config properties, specified on the MDB, which aren't accepted by the resource
        // adaptor
        final Properties validActivationConfigProps = this.filterUnknownActivationConfigProperties(resourceAdapterName, activation, activationConfigProperties);
        // now set the activation config properties on the ActivationSpec
        final ActivationSpec activationSpec = activation.createInstance();
        BeanUtils.mapJavaBeanProperties(activationSpec, validActivationConfigProps);
        return activationSpec;
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (ResourceException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (NotFoundException e) {
        throw new RuntimeException(e);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e);
    }
}
Also used : MessageListener(org.jboss.jca.core.spi.rar.MessageListener) IntrospectionException(java.beans.IntrospectionException) NotFoundException(org.jboss.jca.core.spi.rar.NotFoundException) Activation(org.jboss.jca.core.spi.rar.Activation) Properties(java.util.Properties) ActivationSpec(javax.resource.spi.ActivationSpec) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) ResourceException(javax.resource.ResourceException)

Example 2 with ResourceException

use of javax.resource.ResourceException in project geode by apache.

the class JCALocalTransaction method commit.

@Override
public void commit() throws ResourceException {
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCALocalTransaction:invoked commit");
    }
    TXStateProxy tsp = this.gfTxMgr.getTXState();
    if (tsp != null && this.tid != tsp.getTransactionId()) {
        throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
    }
    try {
        this.gfTxMgr.commit();
        this.tid = null;
    } catch (Exception e) {
        // TODO: consider wrapping the cause
        throw new LocalTransactionException(e.toString());
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) LogWriter(org.apache.geode.LogWriter) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) ResourceException(javax.resource.ResourceException) SystemException(javax.transaction.SystemException) LocalTransactionException(javax.resource.spi.LocalTransactionException)

Example 3 with ResourceException

use of javax.resource.ResourceException in project geode by apache.

the class JCALocalTransaction method rollback.

@Override
public void rollback() throws ResourceException {
    TXStateProxy tsp = this.gfTxMgr.getTXState();
    if (tsp != null && this.tid != tsp.getTransactionId()) {
        throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
    }
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCALocalTransaction:invoked rollback");
    }
    try {
        this.gfTxMgr.rollback();
    } catch (IllegalStateException ise) {
        // It is possible that the GFE transaction has already been rolled back.
        if (ise.getMessage().equals(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString())) {
        // ignore
        } else {
            throw new ResourceException(ise);
        }
    } catch (RuntimeException e) {
        throw new ResourceException(e);
    } finally {
        this.tid = null;
    }
}
Also used : TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) LogWriter(org.apache.geode.LogWriter) ResourceException(javax.resource.ResourceException)

Example 4 with ResourceException

use of javax.resource.ResourceException in project spring-framework by spring-projects.

the class CciLocalTransactionManager method doCommit.

@Override
protected void doCommit(DefaultTransactionStatus status) {
    CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
    Connection con = txObject.getConnectionHolder().getConnection();
    if (status.isDebug()) {
        logger.debug("Committing CCI local transaction on Connection [" + con + "]");
    }
    try {
        con.getLocalTransaction().commit();
    } catch (LocalTransactionException ex) {
        throw new TransactionSystemException("Could not commit CCI local transaction", ex);
    } catch (ResourceException ex) {
        throw new TransactionSystemException("Unexpected failure on commit of CCI local transaction", ex);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) Connection(javax.resource.cci.Connection) ResourceException(javax.resource.ResourceException) TransactionSystemException(org.springframework.transaction.TransactionSystemException)

Example 5 with ResourceException

use of javax.resource.ResourceException in project spring-framework by spring-projects.

the class CciLocalTransactionManager method doRollback.

@Override
protected void doRollback(DefaultTransactionStatus status) {
    CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
    Connection con = txObject.getConnectionHolder().getConnection();
    if (status.isDebug()) {
        logger.debug("Rolling back CCI local transaction on Connection [" + con + "]");
    }
    try {
        con.getLocalTransaction().rollback();
    } catch (LocalTransactionException ex) {
        throw new TransactionSystemException("Could not roll back CCI local transaction", ex);
    } catch (ResourceException ex) {
        throw new TransactionSystemException("Unexpected failure on rollback of CCI local transaction", ex);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) Connection(javax.resource.cci.Connection) ResourceException(javax.resource.ResourceException) TransactionSystemException(org.springframework.transaction.TransactionSystemException)

Aggregations

ResourceException (javax.resource.ResourceException)163 TranslatorException (org.teiid.translator.TranslatorException)26 SQLException (java.sql.SQLException)18 IOException (java.io.IOException)17 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)14 ManagedConnection (javax.resource.spi.ManagedConnection)13 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)13 NamingException (javax.naming.NamingException)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 SObject (com.sforce.soap.partner.sobject.SObject)9 ConnectionException (com.sforce.ws.ConnectionException)9 UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)8 ArrayList (java.util.ArrayList)8 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)7 InvalidSObjectFault (com.sforce.soap.partner.fault.InvalidSObjectFault)6 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)6 Set (java.util.Set)6 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)6 XAResource (javax.transaction.xa.XAResource)6 InvalidFieldFault (com.sforce.soap.partner.fault.InvalidFieldFault)5