Search in sources :

Example 66 with DeploymentUnitProcessingException

use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.

the class RaDeploymentParsingProcessor method process.

public static ConnectorXmlDescriptor process(boolean resolveProperties, VirtualFile file, VirtualFile alternateDescriptor, String deploymentName) throws DeploymentUnitProcessingException {
    // Locate the descriptor
    final VirtualFile serviceXmlFile;
    if (alternateDescriptor != null) {
        serviceXmlFile = alternateDescriptor;
    } else {
        serviceXmlFile = file.getChild("/META-INF/ra.xml");
    }
    InputStream xmlStream = null;
    Connector result = null;
    try {
        if (serviceXmlFile != null && serviceXmlFile.exists()) {
            xmlStream = serviceXmlFile.openStream();
            RaParser raParser = new RaParser();
            raParser.setSystemPropertiesResolved(resolveProperties);
            result = raParser.parse(xmlStream);
            if (result == null)
                throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
        }
        File root = file.getPhysicalFile();
        URL url = root.toURI().toURL();
        return new ConnectorXmlDescriptor(result, root, url, deploymentName);
    } catch (Exception e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
    } finally {
        VFSUtils.safeClose(xmlStream);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) Connector(org.jboss.jca.common.api.metadata.spec.Connector) RaParser(org.jboss.jca.common.metadata.spec.RaParser) InputStream(java.io.InputStream) ConnectorXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor) File(java.io.File) VirtualFile(org.jboss.vfs.VirtualFile) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 67 with DeploymentUnitProcessingException

use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.

the class DsXmlDeploymentInstallProcessor method deploy.

/**
     * Process a deployment for standard ra deployment files. Will parse the xml
     * file and attach a configuration discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<DataSources> dataSourcesList = deploymentUnit.getAttachmentList(DsXmlDeploymentParsingProcessor.DATA_SOURCES_ATTACHMENT_KEY);
    final boolean legacySecurityPresent = phaseContext.getDeploymentUnit().hasAttachment(SecurityAttachments.SECURITY_ENABLED);
    for (DataSources dataSources : dataSourcesList) {
        if (dataSources.getDrivers() != null && dataSources.getDrivers().size() > 0) {
            ConnectorLogger.DS_DEPLOYER_LOGGER.driversElementNotSupported(deploymentUnit.getName());
        }
        ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        if (dataSources.getDataSource() != null && dataSources.getDataSource().size() > 0) {
            for (int i = 0; i < dataSources.getDataSource().size(); i++) {
                DataSource ds = (DataSource) dataSources.getDataSource().get(i);
                if (ds.isEnabled() && ds.getDriver() != null) {
                    try {
                        final String jndiName = Util.cleanJndiName(ds.getJndiName(), ds.isUseJavaContext());
                        LocalDataSourceService lds = new LocalDataSourceService(jndiName, ContextNames.bindInfoFor(jndiName));
                        lds.getDataSourceConfigInjector().inject(buildDataSource(ds));
                        final String dsName = ds.getJndiName();
                        final PathAddress addr = getDataSourceAddress(dsName, deploymentUnit, false);
                        installManagementModel(ds, deploymentUnit, addr);
                        // TODO why have we been ignoring a configured legacy security domain but no legacy security present?
                        boolean useLegacySecurity = legacySecurityPresent && isLegacySecurityRequired(ds.getSecurity());
                        startDataSource(lds, jndiName, ds.getDriver(), serviceTarget, getRegistration(false, deploymentUnit), getResource(dsName, false, deploymentUnit), dsName, useLegacySecurity, ds.isJTA());
                    } catch (Exception e) {
                        throw ConnectorLogger.ROOT_LOGGER.exceptionDeployingDatasource(e, ds.getJndiName());
                    }
                } else {
                    ConnectorLogger.DS_DEPLOYER_LOGGER.debugf("Ignoring: %s", ds.getJndiName());
                }
            }
        }
        if (dataSources.getXaDataSource() != null && dataSources.getXaDataSource().size() > 0) {
            for (int i = 0; i < dataSources.getXaDataSource().size(); i++) {
                XaDataSource xads = (XaDataSource) dataSources.getXaDataSource().get(i);
                if (xads.isEnabled() && xads.getDriver() != null) {
                    try {
                        String jndiName = Util.cleanJndiName(xads.getJndiName(), xads.isUseJavaContext());
                        XaDataSourceService xds = new XaDataSourceService(jndiName, ContextNames.bindInfoFor(jndiName));
                        xds.getDataSourceConfigInjector().inject(buildXaDataSource(xads));
                        final String dsName = xads.getJndiName();
                        final PathAddress addr = getDataSourceAddress(dsName, deploymentUnit, true);
                        installManagementModel(xads, deploymentUnit, addr);
                        // TODO why have we been ignoring a configured legacy security domain but no legacy security present?
                        boolean useLegacySecurity = legacySecurityPresent && isLegacySecurityRequired(xads.getSecurity());
                        startDataSource(xds, jndiName, xads.getDriver(), serviceTarget, getRegistration(true, deploymentUnit), getResource(dsName, true, deploymentUnit), dsName, useLegacySecurity, true);
                    } catch (Exception e) {
                        throw ConnectorLogger.ROOT_LOGGER.exceptionDeployingDatasource(e, xads.getJndiName());
                    }
                } else {
                    ConnectorLogger.DS_DEPLOYER_LOGGER.debugf("Ignoring %s", xads.getJndiName());
                }
            }
        }
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) ModifiableXaDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ModifiableXaDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) ModifiableDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableDataSource) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource) LocalDataSourceService(org.jboss.as.connector.subsystems.datasources.LocalDataSourceService) XaDataSourceService(org.jboss.as.connector.subsystems.datasources.XaDataSourceService) DataSources(org.jboss.jca.common.api.metadata.ds.DataSources) PathAddress(org.jboss.as.controller.PathAddress) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 68 with DeploymentUnitProcessingException

use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.

the class DsXmlDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for standard ra deployment files. Will parse the xml
     * file and attach a configuration discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
    final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER);
    final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER);
    final Set<VirtualFile> files = dataSources(deploymentUnit);
    boolean loggedDeprication = false;
    for (VirtualFile f : files) {
        InputStream xmlStream = null;
        try {
            xmlStream = new FileInputStream(f.getPhysicalFile());
            DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer);
            parser.setSystemPropertiesResolved(resolveProperties);
            DataSources dataSources = parser.parse(xmlStream);
            if (dataSources != null) {
                if (!loggedDeprication) {
                    loggedDeprication = true;
                    ConnectorLogger.ROOT_LOGGER.deprecated();
                }
                for (DataSource ds : dataSources.getDataSource()) {
                    if (ds.getDriver() == null) {
                        throw ConnectorLogger.ROOT_LOGGER.FailedDeployDriverNotSpecified(ds.getJndiName());
                    }
                }
                deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources);
            }
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e.getMessage(), e);
        } finally {
            VFSUtils.safeClose(xmlStream);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) PropertyResolver(org.jboss.metadata.property.PropertyResolver) FileInputStream(java.io.FileInputStream) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource) DataSources(org.jboss.jca.common.api.metadata.ds.DataSources) DsXmlParser(org.jboss.as.connector.deployers.ds.DsXmlParser) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 69 with DeploymentUnitProcessingException

use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.

the class RaNativeProcessor method process.

public static void process(VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
    if (deploymentRoot == null || !deploymentRoot.exists())
        return;
    final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
    if (!deploymentRootName.endsWith(".rar")) {
        return;
    }
    try {
        List<VirtualFile> libs = deploymentRoot.getChildrenRecursively(new LibraryFilter());
        if (libs != null && libs.size() > 0) {
            for (VirtualFile vf : libs) {
                String fileName = vf.getName().toLowerCase(Locale.ENGLISH);
                ROOT_LOGGER.tracef("Processing library: %s", fileName);
                try {
                    File f = vf.getPhysicalFile();
                    System.load(f.getAbsolutePath());
                    ROOT_LOGGER.debugf("Loaded library: %s", f.getAbsolutePath());
                } catch (Throwable t) {
                    ROOT_LOGGER.debugf("Unable to load library: %s", fileName);
                }
            }
        }
    } catch (Exception e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToLoadNativeLibraries(e);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 70 with DeploymentUnitProcessingException

use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.

the class PersistenceProviderHandler method deploy.

public static void deploy(final DeploymentPhaseContext phaseContext, final Platform platform) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
    if (module != null && servicesAttachment != null) {
        final ModuleClassLoader deploymentModuleClassLoader = module.getClassLoader();
        PersistenceProvider provider;
        // collect list of persistence providers packaged with the application
        final List<String> providerNames = servicesAttachment.getServiceImplementations(PERSISTENCE_PROVIDER_CLASSNAME);
        List<PersistenceProvider> providerList = new ArrayList<PersistenceProvider>();
        for (String providerName : providerNames) {
            try {
                final Class<? extends PersistenceProvider> providerClass = deploymentModuleClassLoader.loadClass(providerName).asSubclass(PersistenceProvider.class);
                final Constructor<? extends PersistenceProvider> constructor = providerClass.getConstructor();
                provider = constructor.newInstance();
                providerList.add(provider);
                JpaLogger.ROOT_LOGGER.tracef("deployment %s is using its own copy of %s", deploymentUnit.getName(), providerName);
            } catch (Exception e) {
                throw JpaLogger.ROOT_LOGGER.cannotDeployApp(e, providerName);
            }
        }
        if (providerList.size() > 0) {
            final String adapterClass = deploymentUnit.getAttachment(JpaAttachments.ADAPTOR_CLASS_NAME);
            PersistenceProviderAdaptor adaptor;
            if (adapterClass != null) {
                try {
                    adaptor = (PersistenceProviderAdaptor) deploymentModuleClassLoader.loadClass(adapterClass).newInstance();
                    adaptor.injectJtaManager(new JtaManagerImpl(deploymentUnit.getAttachment(JpaAttachments.TRANSACTION_MANAGER), deploymentUnit.getAttachment(JpaAttachments.TRANSACTION_SYNCHRONIZATION_REGISTRY)));
                    adaptor.injectPlatform(platform);
                    ArrayList<PersistenceProviderAdaptor> adaptorList = new ArrayList<>();
                    adaptorList.add(adaptor);
                    PersistenceProviderDeploymentHolder.savePersistenceProviderInDeploymentUnit(deploymentUnit, providerList, adaptorList);
                } catch (InstantiationException e) {
                    throw JpaLogger.ROOT_LOGGER.cannotCreateAdapter(e, adapterClass);
                } catch (IllegalAccessException e) {
                    throw JpaLogger.ROOT_LOGGER.cannotCreateAdapter(e, adapterClass);
                } catch (ClassNotFoundException e) {
                    throw JpaLogger.ROOT_LOGGER.cannotCreateAdapter(e, adapterClass);
                }
            } else {
                // register the provider (no adapter specified)
                PersistenceProviderDeploymentHolder.savePersistenceProviderInDeploymentUnit(deploymentUnit, providerList, null);
            }
        }
    }
}
Also used : ServicesAttachment(org.jboss.as.server.deployment.ServicesAttachment) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) PersistenceProvider(javax.persistence.spi.PersistenceProvider) ArrayList(java.util.ArrayList) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) JtaManagerImpl(org.jboss.as.jpa.transaction.JtaManagerImpl) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) PersistenceProviderAdaptor(org.jipijapa.plugin.spi.PersistenceProviderAdaptor)

Aggregations

DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)95 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)45 Module (org.jboss.modules.Module)28 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)26 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)26 VirtualFile (org.jboss.vfs.VirtualFile)22 InputStream (java.io.InputStream)20 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)18 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)18 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)18 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)17 ViewDescription (org.jboss.as.ee.component.ViewDescription)16 Method (java.lang.reflect.Method)15 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)15 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)15 ServiceName (org.jboss.msc.service.ServiceName)15 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)14 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)12 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)12