use of javax.resource.ResourceException in project Payara by payara.
the class ContextServiceManager method createConfigBean.
public Resource createConfigBean(final Resources resources, HashMap attributes, final Properties properties, boolean validate) throws Exception {
setAttributes(attributes, null);
ResourceStatus status = null;
if (!validate) {
status = new ResourceStatus(ResourceStatus.SUCCESS, "");
} else {
status = isValid(resources, false, null);
}
if (status.getStatus() == ResourceStatus.SUCCESS) {
return createConfigBean(resources, properties);
} else {
throw new ResourceException(status.getMessage());
}
}
use of javax.resource.ResourceException in project Payara by payara.
the class ConnectorAllocator method createResource.
public ResourceHandle createResource() throws PoolingException {
ClassLoader appClassLoader = Utility.getClassLoader();
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);
} finally {
Utility.setContextClassLoader(appClassLoader);
}
}
use of javax.resource.ResourceException 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);
}
}
use of javax.resource.ResourceException 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);
}
}
use of javax.resource.ResourceException in project Payara by payara.
the class AbstractConnectorAllocator method isConnectionValid.
public boolean isConnectionValid(ResourceHandle h) {
HashSet conn = new HashSet();
conn.add(h.getResource());
Set invalids = null;
try {
invalids = getInvalidConnections(conn);
} catch (ResourceException re) {
// ignore and continue??
// there's nothing the container can do but log it.
Object[] args = new Object[] { h.getResourceSpec().getPoolInfo(), re.getClass(), re.getMessage() };
_logger.log(Level.WARNING, "pool.get_invalid_connections_resourceexception", args);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "", re);
}
}
if ((invalids != null && invalids.size() > 0) || h.hasConnectionErrorOccurred()) {
return false;
}
return true;
}
Aggregations