Search in sources :

Example 41 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class ResourcesDeployer method createAppScopedResources.

private void createAppScopedResources(Application app, List<org.glassfish.resources.api.Resource> resources, DeploymentContext dc, boolean embedded) throws ResourceException {
    try {
        if (resources != null) {
            Application application = dc.getTransientAppMetaData(ServerTags.APPLICATION, Application.class);
            Resources asc = dc.getTransientAppMetaData(APP_META_DATA_RESOURCES, Resources.class);
            if (asc == null) {
                asc = application.createChild(Resources.class);
                application.setResources(asc);
                dc.addTransientAppMetaData(APP_META_DATA_RESOURCES, asc);
                ApplicationInfo appInfo = appRegistry.get(app.getName());
                if (appInfo != null) {
                    appInfo.addTransientAppMetaData(app.getName() + "-resources", asc);
                }
            }
            createConfig(asc, resources, embedded);
            String appName = app.getName();
            preserveResources(asc, appName, appName);
        }
    } catch (Exception e) {
        Object[] params = new Object[] { app.getName(), e };
        _logger.log(Level.SEVERE, "gf.resources.app.scope.deployment.failure", params);
        throw new ResourceException(e);
    }
}
Also used : ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ResourceException(javax.resource.ResourceException) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException)

Example 42 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class CustomResourceManager method createConfigBean.

public Resource createConfigBean(Resources resources, HashMap attributes, 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());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 43 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class ResourcesDeployer method createConfig.

private Collection<Resource> createConfig(Resources resources, Collection<org.glassfish.resources.api.Resource> resourcesToRegister, boolean embedded) throws ResourceException {
    List<Resource> resourceConfigs = new ArrayList<Resource>();
    for (org.glassfish.resources.api.Resource resource : resourcesToRegister) {
        final HashMap attrList = resource.getAttributes();
        final Properties props = resource.getProperties();
        String desc = resource.getDescription();
        if (desc != null) {
            attrList.put("description", desc);
        }
        try {
            final ResourceManager rm = resourceFactory.getResourceManager(resource);
            if (embedded && isEmbeddedResource(resource, resourcesToRegister)) {
                Resource configBeanResource = rm.createConfigBean(resources, attrList, props, false);
                resources.getResources().add(configBeanResource);
                resourceConfigs.add(configBeanResource);
            } else if (!embedded && !isEmbeddedResource(resource, resourcesToRegister)) {
                com.sun.enterprise.config.serverbeans.Resource configBeanResource = rm.createConfigBean(resources, attrList, props, true);
                resources.getResources().add(configBeanResource);
                resourceConfigs.add(configBeanResource);
            }
        } catch (Exception e) {
            throw new ResourceException(e);
        }
    }
    return resourceConfigs;
}
Also used : Resource(com.sun.enterprise.config.serverbeans.Resource) Resource(org.glassfish.resources.api.Resource) ResourceManager(org.glassfish.resources.admin.cli.ResourceManager) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException) Resource(org.glassfish.resources.api.Resource) ResourceException(javax.resource.ResourceException) org.glassfish.resources.api(org.glassfish.resources.api) org.jvnet.hk2.config(org.jvnet.hk2.config)

Example 44 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class JavaMailResourceManager method createConfigBean.

public Resource createConfigBean(Resources resources, HashMap attributes, 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());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 45 with ResourceException

use of javax.resource.ResourceException in project Payara by payara.

the class JndiResourceManager method createConfigBean.

public Resource createConfigBean(Resources resources, HashMap attributes, 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());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Aggregations

ResourceException (javax.resource.ResourceException)179 SQLException (java.sql.SQLException)21 Connection (javax.resource.cci.Connection)20 IOException (java.io.IOException)18 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)14 ManagedConnection (javax.resource.spi.ManagedConnection)14 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)13 Test (org.junit.Test)13 TranslatorException (org.teiid.translator.TranslatorException)13 LocalTransactionException (javax.resource.spi.LocalTransactionException)12 XAResource (javax.transaction.xa.XAResource)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 JMSException (javax.jms.JMSException)10 TransactionSystemException (org.springframework.transaction.TransactionSystemException)10 ConnectionException (com.sforce.ws.ConnectionException)9 NamingException (javax.naming.NamingException)9 NotSupportedException (javax.resource.NotSupportedException)9 UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)8 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)8 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)7