Search in sources :

Example 1 with DeploymentUnitProcessingException

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

the class PersistenceRefProcessor method getPersistenceUnitBindingSource.

private InjectionSource getPersistenceUnitBindingSource(final DeploymentUnit deploymentUnit, final String unitName) throws DeploymentUnitProcessingException {
    final String searchName;
    if (isEmpty(unitName)) {
        searchName = null;
    } else {
        searchName = unitName;
    }
    final PersistenceUnitMetadata pu = PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, searchName);
    if (null == pu) {
        throw new DeploymentUnitProcessingException(JpaLogger.ROOT_LOGGER.persistenceUnitNotFound(searchName, deploymentUnit));
    }
    String scopedPuName = pu.getScopedPersistenceUnitName();
    ServiceName puServiceName = getPuServiceName(scopedPuName);
    return new PersistenceUnitInjectionSource(puServiceName, deploymentUnit.getServiceRegistry(), EntityManagerFactory.class.getName(), pu);
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ServiceName(org.jboss.msc.service.ServiceName) EntityManagerFactory(javax.persistence.EntityManagerFactory) PersistenceUnitInjectionSource(org.jboss.as.jpa.injectors.PersistenceUnitInjectionSource) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata)

Example 2 with DeploymentUnitProcessingException

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

the class KernelDeploymentParsingProcessor method parseDescriptor.

/**
     * Parse -jboss-beans.xml file.
     *
     * @param unit         the deployment unit
     * @param beansXmlFile the beans xml file
     * @throws DeploymentUnitProcessingException
     *          for any error
     */
protected void parseDescriptor(DeploymentUnit unit, VirtualFile beansXmlFile) throws DeploymentUnitProcessingException {
    if (beansXmlFile == null || beansXmlFile.exists() == false)
        return;
    InputStream xmlStream = null;
    try {
        xmlStream = beansXmlFile.openStream();
        final XMLStreamReader reader = inputFactory.createXMLStreamReader(xmlStream);
        final ParseResult<KernelDeploymentXmlDescriptor> result = new ParseResult<KernelDeploymentXmlDescriptor>();
        xmlMapper.parseDocument(result, reader);
        final KernelDeploymentXmlDescriptor xmlDescriptor = result.getResult();
        if (xmlDescriptor != null)
            unit.addToAttachmentList(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
        else
            throw PojoLogger.ROOT_LOGGER.failedToParse(beansXmlFile);
    } catch (DeploymentUnitProcessingException e) {
        throw e;
    } catch (Exception e) {
        throw PojoLogger.ROOT_LOGGER.parsingException(beansXmlFile, e);
    } finally {
        VFSUtils.safeClose(xmlStream);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) KernelDeploymentXmlDescriptor(org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor) IOException(java.io.IOException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 3 with DeploymentUnitProcessingException

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

the class JSFAnnotationProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Map<Class<? extends Annotation>, Set<Class<?>>> instances = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        // Can not continue without index
        return;
    }
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null) {
        // Can not continue without module
        return;
    }
    final ClassLoader classLoader = module.getClassLoader();
    for (FacesAnnotation annotation : FacesAnnotation.values()) {
        final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(annotation.indexName);
        if (annotationInstances == null || annotationInstances.isEmpty()) {
            continue;
        }
        final Set<Class<?>> discoveredClasses = new HashSet<Class<?>>();
        instances.put(annotation.annotationClass, discoveredClasses);
        for (AnnotationInstance annotationInstance : annotationInstances) {
            final AnnotationTarget target = annotationInstance.target();
            if (target instanceof ClassInfo) {
                final DotName className = ClassInfo.class.cast(target).name();
                final Class<?> annotatedClass;
                try {
                    annotatedClass = classLoader.loadClass(className.toString());
                } catch (ClassNotFoundException e) {
                    throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.classLoadingFailed(className));
                }
                discoveredClasses.add(annotatedClass);
            } else {
                throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidAnnotationLocation(annotation, target));
            }
        }
    }
    deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(FACES_ANNOTATIONS_SC_ATTR, instances));
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DotName(org.jboss.jandex.DotName) Annotation(java.lang.annotation.Annotation) ServletContextAttribute(org.jboss.as.web.common.ServletContextAttribute) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 4 with DeploymentUnitProcessingException

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

the class PersistenceUnitParseProcessor method parse.

private void parse(final VirtualFile persistence_xml, final List<PersistenceUnitMetadataHolder> listPUHolders, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    ROOT_LOGGER.tracef("parse checking if %s exists, result = %b", persistence_xml.toString(), persistence_xml.exists());
    if (persistence_xml.exists() && persistence_xml.isFile()) {
        InputStream is = null;
        try {
            is = persistence_xml.openStream();
            final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
            inputFactory.setXMLResolver(NoopXMLResolver.create());
            XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);
            PersistenceUnitMetadataHolder puHolder = PersistenceUnitXmlParser.parse(xmlReader, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
            postParseSteps(persistence_xml, puHolder, deploymentUnit);
            listPUHolders.add(puHolder);
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(JpaLogger.ROOT_LOGGER.failedToParse(persistence_xml), e);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException e) {
            // Ignore
            }
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) InputStream(java.io.InputStream) IOException(java.io.IOException) XMLInputFactory(javax.xml.stream.XMLInputFactory) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 5 with DeploymentUnitProcessingException

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

the class MailSessionDefinitionInjectionSource method getResourceValue.

public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    try {
        MailSessionService mailSessionService = new DirectMailSessionService(provider);
        startMailSession(mailSessionService, jndiName, eeModuleDescription, context, phaseContext.getServiceTarget(), serviceBuilder, injector);
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

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