Search in sources :

Example 66 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 67 with ConnectorRuntimeException

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

the class JdbcRuntimeExtension method getDeferredResourceConfig.

@Override
public DeferredResourceConfig getDeferredResourceConfig(Object resource, Object pool, String resType, String raName) throws ConnectorRuntimeException {
    String resourceAdapterName;
    DeferredResourceConfig resConfig = null;
    // TODO V3 (not to hold specific resource types)
    if (resource instanceof JdbcResource || pool instanceof JdbcConnectionPool) {
        JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
        JdbcResource jdbcResource = (JdbcResource) resource;
        resourceAdapterName = getRANameofJdbcConnectionPool((JdbcConnectionPool) pool);
        resConfig = new DeferredResourceConfig(resourceAdapterName, null, jdbcPool, jdbcResource, null);
        Resource[] resourcesToload = new Resource[] { jdbcPool, jdbcResource };
        resConfig.setResourcesToLoad(resourcesToload);
    } else {
        throw new ConnectorRuntimeException("unsupported resource type : " + resource);
    }
    return resConfig;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JdbcResource(org.glassfish.jdbc.config.JdbcResource) DeferredResourceConfig(com.sun.enterprise.connectors.DeferredResourceConfig) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) Resource(com.sun.enterprise.config.serverbeans.Resource) JdbcResource(org.glassfish.jdbc.config.JdbcResource)

Example 68 with ConnectorRuntimeException

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

the class JdbcDataSource method validateResource.

private void validateResource(ResourceInfo resourceInfo) throws ConnectorRuntimeException {
    ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
    String jndiName = resourceInfo.getName();
    String suffix = ConnectorsUtil.getValidSuffix(jndiName);
    if (suffix != null) {
        // Typically, resource is created without suffix. Try without suffix.
        String tmpJndiName = jndiName.substring(0, jndiName.lastIndexOf(suffix));
        if (resourcesUtil.getResource(tmpJndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName(), JdbcResource.class) != null) {
            return;
        }
    }
    if (resourcesUtil.getResource(resourceInfo, JdbcResource.class) == null) {
        throw new ConnectorRuntimeException("Invalid resource : " + resourceInfo);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JdbcResource(org.glassfish.jdbc.config.JdbcResource) ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil)

Example 69 with ConnectorRuntimeException

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

the class JMSDestination method _getMQJMXConnectorInfoForCluster.

/**
 *  Gets the <code>MQJMXConnector</code> object for a cluster. Since this code is
 *  executed in DAS, an admin API is used to resolve hostnames and ports of
 *  cluster instances for LOCAL type brokers while creating the connectionURL.
 */
protected MQJMXConnectorInfo _getMQJMXConnectorInfoForCluster(String target, JmsService jmsService, Class mqRAClassName, ServerContext serverContext) throws ConnectorRuntimeException {
    // Create a new RA instance.
    ResourceAdapter raInstance = null;
    // Set the ConnectionURL
    MQAddressList list = null;
    try {
        if (jmsService.getType().equalsIgnoreCase(ActiveJmsResourceAdapter.REMOTE)) {
            list = getDefaultAddressList(jmsService);
        } else {
            list = new MQAddressList();
            CommandTarget ctarget = this.getTypeForTarget(target);
            if (ctarget == CommandTarget.CLUSTER) {
                Server[] servers = list.getServersInCluster(target);
                if (servers != null && servers.length > 0)
                    list.setInstanceName(servers[0].getName());
            } else if (ctarget == CommandTarget.CLUSTERED_INSTANCE) {
                list.setInstanceName(target);
            }
            java.util.Map<String, JmsHost> hostMap = list.getResolvedLocalJmsHostsInMyCluster(true);
            if (hostMap.size() == 0) {
                String msg = localStrings.getLocalString("mqjmx.no_jms_hosts", "No JMS Hosts Configured");
                throw new ConnectorRuntimeException(msg);
            }
            for (JmsHost host : hostMap.values()) {
                list.addMQUrl(host);
            }
        }
        String connectionUrl = list.toString();
        String adminUserName = null;
        String adminPassword = null;
        JmsHost jmsHost = list.getDefaultJmsHost(jmsService);
        if (jmsHost != null) {
            // && jmsHost.isEnabled()) {
            adminUserName = jmsHost.getAdminUserName();
            adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
        } else {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, " _getMQJMXConnectorInfo, using default jms admin user and password ");
            }
        }
        raInstance = getConfiguredRA(mqRAClassName, connectionUrl, adminUserName, adminPassword);
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
    try {
        String jmxServiceURL = null, jmxServiceURLList = null;
        Map<String, ?> jmxConnectorEnv = null;
        Method[] methds = raInstance.getClass().getMethods();
        for (int i = 0; i < methds.length; i++) {
            Method m = methds[i];
            if (m.getName().equalsIgnoreCase("get" + JMXSERVICEURLLIST)) {
                jmxServiceURLList = (String) m.invoke(raInstance, new Object[] {});
                if (jmxServiceURLList != null && !jmxServiceURLList.trim().equals("")) {
                    jmxServiceURL = getFirstJMXServiceURL(jmxServiceURLList);
                }
            } else if (m.getName().equalsIgnoreCase("get" + JMXCONNECTORENV)) {
                jmxConnectorEnv = (Map<String, ?>) m.invoke(raInstance, new Object[] {});
            }
        }
        MQJMXConnectorInfo mqInfo = new MQJMXConnectorInfo(target, ActiveJmsResourceAdapter.getBrokerInstanceName(jmsService), jmsService.getType(), jmxServiceURL, jmxConnectorEnv);
        return mqInfo;
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList) CommandTarget(org.glassfish.config.support.CommandTarget) Method(java.lang.reflect.Method) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) java.util(java.util) ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ResourceAdapter(javax.resource.spi.ResourceAdapter) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)69 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)12 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 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 IOException (java.io.IOException)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 File (java.io.File)3