Search in sources :

Example 26 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class ContextServiceManager method createConfigBean.

public Resource createConfigBean(final Resources resources, HashMap attributes, final Properties properties, boolean validate) throws Exception {
    setAttributes(attributes, null);
    ResourceStatus status = null;
    if (!validate) {
        status = new ResourceStatus(ResourceStatus.SUCCESS, "");
    } else {
        status = isValid(resources, false, null);
    }
    if (status.getStatus() == ResourceStatus.SUCCESS) {
        return createConfigBean(resources, properties);
    } else {
        throw new ResourceException(status.getMessage());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 27 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class ConnectorAllocator method createResource.

public ResourceHandle createResource() throws PoolingException {
    ClassLoader appClassLoader = Utility.getClassLoader();
    try {
        ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo);
        ResourceHandle resource = createResourceHandle(mc, spec, this, info);
        ConnectionEventListener l = new ConnectionListenerImpl(resource);
        mc.addConnectionEventListener(l);
        return resource;
    } catch (ResourceException ex) {
        Object[] params = new Object[] { spec.getPoolInfo(), ex.toString() };
        _logger.log(Level.WARNING, "poolmgr.create_resource_error", params);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Resource Exception while creating resource", ex);
        }
        if (ex.getLinkedException() != null) {
            _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex.getLinkedException().toString());
        }
        throw new PoolingException(ex);
    } finally {
        Utility.setContextClassLoader(appClassLoader);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ResourceException(javax.resource.ResourceException)

Example 28 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class NoTxConnectorAllocator method createResource.

public ResourceHandle createResource() throws PoolingException {
    try {
        ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo);
        ResourceHandle resource = createResourceHandle(mc, spec, this, info);
        ConnectionEventListener l = new ConnectionListenerImpl(resource);
        mc.addConnectionEventListener(l);
        return resource;
    } catch (ResourceException ex) {
        Object[] params = new Object[] { spec.getPoolInfo(), ex.toString() };
        _logger.log(Level.WARNING, "poolmgr.create_resource_error", params);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Resource Exception while creating resource", ex);
        }
        if (ex.getLinkedException() != null) {
            _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex.getLinkedException().toString());
        }
        throw new PoolingException(ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ManagedConnection(javax.resource.spi.ManagedConnection) ResourceException(javax.resource.ResourceException) ConnectionEventListener(com.sun.enterprise.resource.listener.ConnectionEventListener)

Example 29 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class AbstractConnectorAllocator method closeUserConnection.

public void closeUserConnection(ResourceHandle resource) throws PoolingException {
    try {
        ManagedConnection mc = (ManagedConnection) resource.getResource();
        mc.cleanup();
    } catch (ResourceException ex) {
        throw new PoolingException(ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ManagedConnection(javax.resource.spi.ManagedConnection) ResourceException(javax.resource.ResourceException)

Example 30 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class AbstractConnectorAllocator method isConnectionValid.

public boolean isConnectionValid(ResourceHandle h) {
    HashSet conn = new HashSet();
    conn.add(h.getResource());
    Set invalids = null;
    try {
        invalids = getInvalidConnections(conn);
    } catch (ResourceException re) {
        // ignore and continue??
        // there's nothing the container can do but log it.
        Object[] args = new Object[] { h.getResourceSpec().getPoolInfo(), re.getClass(), re.getMessage() };
        _logger.log(Level.WARNING, "pool.get_invalid_connections_resourceexception", args);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "", re);
        }
    }
    if ((invalids != null && invalids.size() > 0) || h.hasConnectionErrorOccurred()) {
        return false;
    }
    return true;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ResourceException(javax.resource.ResourceException) HashSet(java.util.HashSet)

Aggregations

ResourceException (javax.resource.ResourceException)165 SQLException (java.sql.SQLException)19 IOException (java.io.IOException)18 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)14 ManagedConnection (javax.resource.spi.ManagedConnection)14 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)13 TranslatorException (org.teiid.translator.TranslatorException)13 Connection (javax.resource.cci.Connection)12 Test (org.junit.Test)12 NamingException (javax.naming.NamingException)11 XAResource (javax.transaction.xa.XAResource)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 ConnectionException (com.sforce.ws.ConnectionException)9 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)9 UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)8 JMSException (javax.jms.JMSException)8 LocalTransactionException (javax.resource.spi.LocalTransactionException)8 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)7 ArrayList (java.util.ArrayList)7 NotSupportedException (javax.resource.NotSupportedException)7