Search in sources :

Example 6 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class UnpooledResource method getUnenlistedResource.

@Override
protected ResourceHandle getUnenlistedResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException {
    ResourceHandle handle = null;
    if (incrementPoolSize()) {
        try {
            handle = createSingleResource(alloc);
        } catch (PoolingException ex) {
            decrementPoolSize();
            throw ex;
        }
        ResourceState state = new ResourceState();
        handle.setResourceState(state);
        state.setEnlisted(false);
        setResourceStateToBusy(handle);
        return handle;
    }
    String msg = localStrings.getStringWithDefault("poolmgr.max.pool.size.reached", "In-use connections equal max-pool-size therefore cannot allocate any more connections.");
    throw new PoolingException(msg);
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ResourceState(com.sun.enterprise.resource.ResourceState)

Example 7 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class DataStructureFactory method initializeCustomDataStructureInPrivilegedMode.

private static DataStructure initializeCustomDataStructureInPrivilegedMode(final String className, final String parameters, final int maxPoolSize, final ResourceHandler handler, final String strategyClass) throws PoolingException {
    Object result = AccessController.doPrivileged(new PrivilegedAction() {

        public Object run() {
            Object result = null;
            try {
                result = initializeDataStructure(className, parameters, maxPoolSize, handler, strategyClass);
            } catch (Exception e) {
                _logger.log(Level.WARNING, "pool.datastructure.init.failure", className);
                _logger.log(Level.WARNING, "pool.datastructure.init.failure.exception", e);
            }
            return result;
        }
    });
    if (result != null) {
        return (DataStructure) result;
    } else {
        throw new PoolingException("Unable to initalize custom DataStructure : " + className);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) PrivilegedAction(java.security.PrivilegedAction) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException)

Example 8 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class SystemResourceManagerImpl method enlistResource.

/**
 * Register the <code>ResourceHandle</code> in the transaction
 *
 * @param handle	<code>ResourceHandle</code> object
 * @exception <code>PoolingException</code> If there is any error while
 *        enlisting.
 */
public void enlistResource(ResourceHandle handle) throws PoolingException {
    try {
        JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
        Transaction tran = tm.getTransaction();
        if (tran != null) {
            tm.enlistResource(tran, handle);
        }
    } catch (Exception ex) {
        _logger.log(Level.SEVERE, "poolmgr.unexpected_exception", ex);
        throw new PoolingException(ex.toString(), ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) Transaction(javax.transaction.Transaction) JavaEETransactionManager(com.sun.enterprise.transaction.api.JavaEETransactionManager) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) SystemException(javax.transaction.SystemException)

Example 9 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class ConnectorAllocator method destroyResource.

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

Example 10 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class ConnectorAllocator 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) ResourceException(javax.resource.ResourceException)

Aggregations

PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)32 ResourceException (javax.resource.ResourceException)17 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)9 ManagedConnection (javax.resource.spi.ManagedConnection)7 InvocationException (org.glassfish.api.invocation.InvocationException)5 PrivilegedAction (java.security.PrivilegedAction)4 RetryableUnavailableException (javax.resource.spi.RetryableUnavailableException)4 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)3 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)3 NamingException (javax.naming.NamingException)3 SystemException (javax.transaction.SystemException)3 XAResource (javax.transaction.xa.XAResource)3 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)3 InvocationManager (org.glassfish.api.invocation.InvocationManager)3 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 ResourceSpec (com.sun.enterprise.resource.ResourceSpec)2 ConnectionEventListener (com.sun.enterprise.resource.listener.ConnectionEventListener)2 PoolManager (com.sun.enterprise.resource.pool.PoolManager)2 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)2 Transaction (javax.transaction.Transaction)2