Search in sources :

Example 11 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException 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 12 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException 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 13 with PoolingException

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

the class ConnectorConnectionPoolAdminServiceImpl method updateMCFAndPoolAttributes.

private void updateMCFAndPoolAttributes(ConnectorConnectionPool ccp) throws ConnectorRuntimeException {
    PoolInfo poolInfo = ccp.getPoolInfo();
    try {
        ConnectorConnectionPool origCcp = getOriginalConnectorConnectionPool(poolInfo);
        // update properties
        origCcp.setSteadyPoolSize(ccp.getSteadyPoolSize());
        origCcp.setMaxPoolSize(ccp.getMaxPoolSize());
        origCcp.setMaxWaitTimeInMillis(ccp.getMaxWaitTimeInMillis());
        origCcp.setPoolResizeQuantity(ccp.getPoolResizeQuantity());
        origCcp.setIdleTimeoutInSeconds(ccp.getIdleTimeoutInSeconds());
        origCcp.setFailAllConnections(ccp.isFailAllConnections());
        // lazyEnlist, lazyAssoc and assocWithThread not required since they result
        // in a pool restart anyways, so they wouldn't have changed if we
        // came here
        origCcp.setMatchConnections(ccp.matchConnections());
        origCcp.setMaxConnectionUsage(ccp.getMaxConnectionUsage());
        origCcp.setNonComponent(ccp.isNonComponent());
        origCcp.setNonTransactional(ccp.isNonTransactional());
        origCcp.setConCreationRetryAttempts(ccp.getConCreationRetryAttempts());
        origCcp.setConCreationRetryInterval(ccp.getConCreationRetryInterval());
        origCcp.setValidateAtmostOncePeriod(ccp.getValidateAtmostOncePeriod());
        origCcp.setConnectionLeakTracingTimeout(ccp.getConnectionLeakTracingTimeout());
        origCcp.setConnectionReclaim(ccp.isConnectionReclaim());
        // now rebind the object in jndi
        String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
        _runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool);
        _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, origCcp, true);
    } catch (NamingException ne) {
        throw new ConnectorRuntimeException(ne.getMessage());
    }
    // Check if this pool has been brought into memory
    // If its already in memory, just call reconfig on it
    PoolManager poolMgr = _runtime.getPoolManager();
    try {
        poolMgr.reconfigPoolProperties(ccp);
    } catch (PoolingException pe) {
        throw new ConnectorRuntimeException(pe.getMessage());
    }
    // Run setXXX methods on the copy of the MCF that we have
    // this is done to update the MCF to reflect changes in the
    // MCF properties for which we don't really need to recreate
    // the pool
    ConnectorRegistry registry = ConnectorRegistry.getInstance();
    ManagedConnectionFactory mcf = registry.getManagedConnectionFactory(poolInfo);
    SetMethodAction sma = new SetMethodAction(mcf, ccp.getConnectorDescriptorInfo().getMCFConfigProperties());
    try {
        sma.run();
    } catch (Exception e) {
        _logger.log(Level.WARNING, e.getMessage());
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
    // update the properties "allow-non-component-callers" and
    // "non-transactional-connections" in the PoolMetaData
    PoolMetaData pmd = registry.getPoolMetaData(poolInfo);
    pmd.setIsPM(ccp.isNonComponent());
    pmd.setIsNonTx(ccp.isNonTransactional());
    pmd.setAuthCredentialsDefinedInPool(ccp.getAuthCredentialsDefinedInPool());
    logFine("Pool properties reconfiguration done");
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) NamingException(javax.naming.NamingException) PoolManager(com.sun.enterprise.resource.pool.PoolManager) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) SQLException(java.sql.SQLException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 14 with PoolingException

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

the class BasicResourceAllocator method createResource.

public ResourceHandle createResource(XAResource xaResource) throws PoolingException {
    ResourceHandle resourceHandle = null;
    ResourceSpec spec = new ResourceSpec(JMS_RESOURCE_FACTORY, ResourceSpec.JMS);
    if (xaResource != null) {
        logger.logp(Level.FINEST, "BasicResourceAllocator", "createResource", "NOT NULL", xaResource);
        try {
            resourceHandle = new ResourceHandle(// no object present
            null, spec, this, null);
            if (logger.isLoggable(Level.FINEST)) {
                xaResource = new XAResourceWrapper(xaResource);
            }
            resourceHandle.fillInResourceObjects(null, xaResource);
        } catch (Exception e) {
            throw (PoolingException) (new PoolingException()).initCause(e);
        }
    } else {
        logger.logp(Level.FINEST, "BasicResourceAllocator", "createResource", "NULL");
    }
    return resourceHandle;
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ResourceSpec(com.sun.enterprise.resource.ResourceSpec) XAResourceWrapper(com.sun.enterprise.resource.XAResourceWrapper) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException)

Example 15 with PoolingException

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

the class ConnectionManagerImpl method internalGetConnection.

protected Object internalGetConnection(ManagedConnectionFactory mcf, final ResourcePrincipal prin, ConnectionRequestInfo cxRequestInfo, boolean shareable, String jndiNameToUse, Object conn, boolean isUnknownAuth) throws ResourceException {
    try {
        PoolManager poolmgr = ConnectorRuntime.getRuntime().getPoolManager();
        ConnectorRegistry registry = ConnectorRegistry.getInstance();
        PoolMetaData pmd = registry.getPoolMetaData(poolInfo);
        ResourceSpec spec = new ResourceSpec(jndiNameToUse, ResourceSpec.JNDI_NAME, pmd);
        spec.setPoolInfo(this.poolInfo);
        ManagedConnectionFactory freshMCF = pmd.getMCF();
        if (getLogger().isLoggable(Level.INFO)) {
            if (!freshMCF.equals(mcf)) {
                getLogger().info("conmgr.mcf_not_equal");
            }
        }
        ConnectorDescriptor desc = registry.getDescriptor(rarName);
        Subject subject = null;
        ClientSecurityInfo info = null;
        boolean subjectDefined = false;
        if (isUnknownAuth && rarName.equals(ConnectorConstants.DEFAULT_JMS_ADAPTER) && !(pmd.isAuthCredentialsDefinedInPool())) {
            // System.out.println("Unkown Auth - pobably nonACC client");
            // Unknown authorization. This is the case for standalone java clients,
            // where the authorization is neither container nor component
            // managed. In this case we associate an non-null Subject with no
            // credentials, so that the RA can either use its own custom logic
            // for figuring out the credentials. Relevant connector spec section
            // is 9.1.8.2.
            // create non-null Subject associated with no credentials
            // System.out.println("RAR name "+ rarName);
            subject = ConnectionPoolObjectsUtils.createSubject(mcf, null);
        } else {
            if (prin == null) {
                info = new ClientSecurityInfo(cxRequestInfo);
            } else {
                info = new ClientSecurityInfo(prin);
                if (prin.equals(defaultPrin)) {
                    subject = pmd.getSubject();
                } else {
                    subject = ConnectionPoolObjectsUtils.createSubject(mcf, prin);
                }
            }
        }
        int txLevel = pmd.getTransactionSupport();
        if (getLogger().isLoggable(Level.FINE)) {
            logFine("ConnectionMgr: poolName " + poolInfo + "  txLevel : " + txLevel);
        }
        if (conn != null) {
            spec.setConnectionToAssociate(conn);
        }
        return getResource(txLevel, poolmgr, mcf, spec, subject, cxRequestInfo, info, desc, shareable);
    } catch (PoolingException ex) {
        Object[] params = new Object[] { poolInfo, ex };
        getLogger().log(Level.WARNING, "poolmgr.get_connection_failure", params);
        // GLASSFISH-19609
        // we can't simply look for ResourceException and throw back since
        // Connector Container also throws ResourceException which might
        // hide the SecurityException thrown by RA.
        // So, we try to track SecurityException
        unwrapSecurityException(ex);
        String i18nMsg = getLocalStrings().getString("con_mgr.error_creating_connection", ex.getMessage());
        ResourceAllocationException rae = new ResourceAllocationException(i18nMsg);
        rae.initCause(ex);
        throw rae;
    }
}
Also used : ClientSecurityInfo(com.sun.enterprise.resource.ClientSecurityInfo) ResourceSpec(com.sun.enterprise.resource.ResourceSpec) PoolManager(com.sun.enterprise.resource.pool.PoolManager) Subject(javax.security.auth.Subject) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor)

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