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;
}
}
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;
}
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);
}
}
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;
}
}
Aggregations