Search in sources :

Example 36 with ConnectorRuntimeException

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

the class AdministeredObjectFactory method getObjectInstance.

public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception {
    Reference ref = (Reference) obj;
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("AdministeredObjectFactory: " + ref + " Name:" + name);
    }
    AdministeredObjectResource aor = (AdministeredObjectResource) ref.get(0).getContent();
    String moduleName = aor.getResourceAdapter();
    // If call fom application client, start resource adapter lazily.
    // todo: Similar code in ConnectorObjectFactory - to refactor.
    ConnectorRuntime runtime = ConnectorNamingUtils.getRuntime();
    if (runtime.isACCRuntime() || runtime.isNonACCRuntime()) {
        ConnectorDescriptor connectorDescriptor = null;
        try {
            Context ic = new InitialContext(env);
            String descriptorJNDIName = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForDescriptor(moduleName);
            connectorDescriptor = (ConnectorDescriptor) ic.lookup(descriptorJNDIName);
        } catch (NamingException ne) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "Failed to look up ConnectorDescriptor " + "from JNDI", moduleName);
            }
            throw new ConnectorRuntimeException("Failed to look up " + "ConnectorDescriptor from JNDI");
        }
        runtime.createActiveResourceAdapter(connectorDescriptor, moduleName, null);
    }
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    if (runtime.checkAccessibility(moduleName, loader) == false) {
        throw new NamingException("Only the application that has the embedded resource" + "adapter can access the resource adapter");
    }
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("[AdministeredObjectFactory] ==> Got AdministeredObjectResource = " + aor);
    }
    // all RARs except system RARs should have been available now.
    if (ConnectorsUtil.belongsToSystemRA(moduleName)) {
        // make sure that system rar is started and hence added to connector classloader chain
        if (ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName) == null) {
            String moduleLocation = ConnectorsUtil.getSystemModuleLocation(moduleName);
            runtime.createActiveResourceAdapter(moduleLocation, moduleName, null);
        }
        loader = ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName).getClassLoader();
    } else if (runtime.isServer()) {
        if (ConnectorsUtil.isStandAloneRA(moduleName)) {
            loader = ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName).getClassLoader();
        }
    }
    return aor.createAdministeredObject(loader);
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AdministeredObjectResource(com.sun.enterprise.resource.beans.AdministeredObjectResource) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 37 with ConnectorRuntimeException

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

the class JdbcConnectionPoolDeployer method redeployResource.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void redeployResource(Object resource) throws Exception {
    final JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(adminPool);
    if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("The JDBC connection pool " + poolInfo + " is not referred or not yet created in this server " + "instance and hence pool redeployment is ignored");
        }
        return;
    }
    final ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
    if (connConnPool == null) {
        throw new ConnectorRuntimeException("Unable to create ConnectorConnectionPool" + "from JDBC connection pool");
    }
    // now do internal book keeping
    HashSet excludes = new HashSet();
    // add MCF config props to the set that need to be excluded
    // in checking for the equality of the props with old pool
    excludes.add("TransactionIsolation");
    excludes.add("GuaranteeIsolationLevel");
    excludes.add("ValidationTableName");
    excludes.add("ConnectionValidationRequired");
    excludes.add("ValidationMethod");
    excludes.add("StatementWrapping");
    excludes.add("StatementTimeout");
    excludes.add("ValidationClassName");
    excludes.add("StatementCacheSize");
    excludes.add("StatementCacheType");
    excludes.add("StatementLeakTimeoutInSeconds");
    excludes.add("StatementLeakReclaim");
    try {
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("Calling reconfigure pool");
        }
        boolean requirePoolRecreation = runtime.reconfigureConnectorConnectionPool(connConnPool, excludes);
        if (requirePoolRecreation) {
            if (runtime.isServer() || runtime.isEmbedded()) {
                handlePoolRecreation(connConnPool);
            } else {
                recreatePool(connConnPool);
            }
        }
    } catch (ConnectorRuntimeException cre) {
        Object[] params = new Object[] { poolInfo, cre };
        _logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) HashSet(java.util.HashSet)

Example 38 with ConnectorRuntimeException

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

the class ActiveResourceAdapterImpl method deleteSunRAConnectionPool.

/**
 * Added to clean up the connector connection pool pertaining to sun-ra.xml. This is
 * only for 1.0 complient rars.
 */
private void deleteSunRAConnectionPool() {
    String defaultPoolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefs_[0].getConnectionFactoryIntf());
    String sunRAPoolName = defaultPoolName + ConnectorConstants.SUN_RA_POOL;
    PoolInfo poolInfo = new PoolInfo(sunRAPoolName);
    try {
        connectorRuntime_.deleteConnectorConnectionPool(poolInfo);
    } catch (ConnectorRuntimeException cre) {
        _logger.log(Level.WARNING, "rar.undeployment.sun_ra_pool_delete_fail", poolInfo);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 39 with ConnectorRuntimeException

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

the class ConnectorService method loadResourcesAndItsRar.

/*    public boolean checkAndLoadResource(Object resource, Object pool, String resourceType, String resourceName,
                                        String raName)
            throws ConnectorRuntimeException {
        String resname = ConnectorAdminServiceUtils.getOriginalResourceName(resourceName);
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ConnectorService :: checkAndLoadResource resolved to load " + resname);
        }

        DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(resource, pool, resourceType, raName);
        //DeferredResourceConfig defResConfig = resUtil.getDeferredResourceConfig(resname);
        return loadResourcesAndItsRar(defResConfig);
    }
*/
public boolean loadResourcesAndItsRar(DeferredResourceConfig defResConfig) {
    if (defResConfig != null) {
        try {
            loadDeferredResources(defResConfig.getResourceAdapterConfig());
            final String rarName = defResConfig.getRarName();
            loadDeferredResourceAdapter(rarName);
            final Resource[] resToLoad = defResConfig.getResourcesToLoad();
            AccessController.doPrivileged(new PrivilegedAction() {

                public Object run() {
                    try {
                        loadDeferredResources(resToLoad);
                    } catch (Exception ex) {
                        Object[] params = new Object[] { rarName, ex };
                        _logger.log(Level.SEVERE, "failed.to.load.deferred.resources", params);
                    }
                    return null;
                }
            });
        } catch (Exception ex) {
            Object[] params = new Object[] { defResConfig.getRarName(), ex };
            _logger.log(Level.SEVERE, "failed.to.load.deferred.ra", params);
            return false;
        }
        return true;
    }
    return false;
}
Also used : PrivilegedAction(java.security.PrivilegedAction) Resource(com.sun.enterprise.config.serverbeans.Resource) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 40 with ConnectorRuntimeException

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

the class ConnectorService method getConnectorDescriptor.

/**
 * Obtains the connector Descriptor pertaining to rar.
 * If ConnectorDescriptor is present in registry, it is obtained from
 * registry and returned. Else it is explicitly read from directory
 * where rar is exploded.
 *
 * @param rarName Name of the rar
 * @return ConnectorDescriptor pertaining to rar.
 * @throws ConnectorRuntimeException when unable to get descriptor
 */
public ConnectorDescriptor getConnectorDescriptor(String rarName) throws ConnectorRuntimeException {
    if (rarName == null) {
        return null;
    }
    ConnectorDescriptor desc = null;
    desc = _registry.getDescriptor(rarName);
    if (desc != null) {
        return desc;
    }
    String moduleDir;
    // using the applicationarchivist
    if (rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) != -1) {
        try {
            desc = loadConnectorDescriptorForEmbeddedRAR(rarName);
            if (desc != null)
                return desc;
        } catch (ConnectorRuntimeException e) {
            throw e;
        }
    }
    if (ConnectorsUtil.belongsToSystemRA(rarName)) {
        moduleDir = ConnectorsUtil.getSystemModuleLocation(rarName);
    } else {
        moduleDir = ConnectorsUtil.getLocation(rarName);
    }
    if (moduleDir != null) {
        desc = ConnectorDDTransformUtils.getConnectorDescriptor(moduleDir, rarName);
    } else {
        _logger.log(Level.SEVERE, "rardeployment.no_module_deployed", rarName);
    }
    return desc;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)71 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)13 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)10 PrivilegedActionException (java.security.PrivilegedActionException)9 ExecutionException (java.util.concurrent.ExecutionException)8 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)8 MultiException (org.glassfish.hk2.api.MultiException)8 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)7 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)5 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)5 IOException (java.io.IOException)5 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)4 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)3