Search in sources :

Example 16 with PoolingException

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

the class ConnectorXAResource method getResourceHandle.

private ResourceHandle getResourceHandle(boolean beginTxIfNeeded) throws PoolingException {
    try {
        ResourceHandle h = null;
        JavaEETransaction j2eetran = getCurrentTransaction();
        if (j2eetran == null) {
            // Only if some thing is wrong with tx manager.
            // Just return the local handle.
            h = localHandle_;
        } else {
            h = (ResourceHandle) j2eetran.getNonXAResource();
            // can be acquired. If the resource in question is not the one in transaction, fail
            if (!localHandle_.isShareable()) {
                if (h != localHandle_) {
                    throw new ResourceAllocationException("Cannot use more than one local-tx resource in unshareable scope");
                }
            }
        }
        if (beginTxIfNeeded && h.getResourceState().isUnenlisted()) {
            ManagedConnection mc = (ManagedConnection) h.getResource();
            // begin the local transaction if first time
            // this ManagedConnection is used in this JTA transaction
            mc.getLocalTransaction().begin();
        }
        return h;
    } catch (Exception ex) {
        _logger.log(Level.SEVERE, "poolmgr.system_exception", ex);
        throw new PoolingException(ex.toString(), ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ManagedConnection(javax.resource.spi.ManagedConnection) ResourceAllocationException(javax.resource.spi.ResourceAllocationException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) SystemException(javax.transaction.SystemException) XAException(javax.transaction.xa.XAException) ResourceAllocationException(javax.resource.spi.ResourceAllocationException)

Example 17 with PoolingException

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

the class ConnectorAllocator method fillInResourceObjects.

public void fillInResourceObjects(ResourceHandle resource) throws PoolingException {
    try {
        ManagedConnection mc = (ManagedConnection) resource.getResource();
        Object con = mc.getConnection(subject, reqInfo);
        resource.incrementCount();
        XAResource xares = mc.getXAResource();
        resource.fillInResourceObjects(con, xares);
    } catch (ResourceException ex) {
        throw new PoolingException(ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) XAResource(javax.transaction.xa.XAResource) ResourceException(javax.resource.ResourceException)

Example 18 with PoolingException

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

the class NoTxConnectorAllocator method fillInResourceObjects.

public void fillInResourceObjects(ResourceHandle resource) throws PoolingException {
    try {
        ManagedConnection mc = (ManagedConnection) resource.getResource();
        Object con = mc.getConnection(subject, reqInfo);
        resource.fillInResourceObjects(con, null);
    } 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 19 with PoolingException

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

the class NoTxConnectorAllocator method destroyResource.

public void destroyResource(ResourceHandle resource) throws PoolingException {
    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) ManagedConnection(javax.resource.spi.ManagedConnection) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException)

Example 20 with PoolingException

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

the class AdministeredObjectResource method createAdministeredObject.

// called by com.sun.enterprise.naming.factory.AdministeredObjectFactory
// FIXME.  embedded??
public Object createAdministeredObject(ClassLoader jcl) throws PoolingException {
    try {
        if (jcl == null) {
            // use context class loader
            jcl = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {

                public Object run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });
        }
        Object adminObject = jcl.loadClass(adminObjectClass_).newInstance();
        AccessController.doPrivileged(new SetMethodAction(adminObject, configProperties_));
        // associate ResourceAdapter if the admin-object is RAA
        if (adminObject instanceof ResourceAdapterAssociation) {
            try {
                ResourceAdapter ra = ConnectorRegistry.getInstance().getActiveResourceAdapter(resadapter_).getResourceAdapter();
                ((ResourceAdapterAssociation) adminObject).setResourceAdapter(ra);
            } catch (ResourceException ex) {
                _logger.log(Level.SEVERE, "rardeployment.assoc_failed", ex);
            }
        }
        // At this stage, administered object is instantiated, config properties applied
        // validate administered object
        // ConnectorRuntime should be available in CLIENT mode now as admin-object-factory would have bootstapped
        // connector-runtime.
        ConnectorRuntime.getRuntime().getConnectorBeanValidator().validateJavaBean(adminObject, resadapter_);
        return adminObject;
    } catch (PrivilegedActionException ex) {
        throw (PoolingException) (new PoolingException().initCause(ex));
    } catch (Exception ex) {
        throw (PoolingException) (new PoolingException().initCause(ex));
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceAdapterAssociation(javax.resource.spi.ResourceAdapterAssociation) PrivilegedAction(java.security.PrivilegedAction) PrivilegedActionException(java.security.PrivilegedActionException) ResourceAdapter(javax.resource.spi.ResourceAdapter) AdminObject(com.sun.enterprise.deployment.AdminObject) ResourceException(javax.resource.ResourceException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) PrivilegedActionException(java.security.PrivilegedActionException) ResourceException(javax.resource.ResourceException) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

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