无法将JSF + CDI项目从Tomcat迁移到Wildfly

时间:2014-08-29 21:06:35

标签: maven jboss wildfly weld wildfly-8

Hello网络开发人员,我正在将我的项目从Tomcat + Weld迁移到WildFly的JSF + CDI,所以我删除了让cdi使用tomcat所需的web.xml配置,并从我的pom.xml中删除了Weld依赖项。问题是我无法让我的项目在Wildfly上运行,我不知道导致问题的原因,我将发布我的pom.xml和WildFly启动日志的一部分,因此你可以分析因为它太长,tyvm。 / p>

-----------------------的pom.xml --------------------- -----------------------

http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0     com.br.logtec.maxgerente     MAX-人Gerente     0.0.1-SNAPSHOT     战争     Max Gerente

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.7</maven.compiler.target>
    <maven.compiler.source>1.7</maven.compiler.source>
</properties>

<repositories>
    <repository>
        <id>JBoss Repository</id>
        <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-web-7.0</artifactId>
            <version>1.0.0.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>org.jboss.spec.javax.ejb</groupId>
        <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- JSF Dependencies -->

    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.0.2-b10</version>
        <scope>compile</scope>
    </dependency>

    <!-- CDI Dependencies -->

    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Common Annotations -->
    <dependency>
        <groupId>org.jboss.spec.javax.annotation</groupId>
        <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Servlet -->
    <dependency>
        <groupId>org.jboss.spec.javax.servlet</groupId>
        <artifactId>jboss-servlet-api_3.1_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.solder</groupId>
        <artifactId>solder-impl</artifactId>
        <version>3.1.1.Final</version>
    </dependency>

    <!-- Seam Faces precisa do seam-international(mesmo que você não use para 
        nada) -->
    <dependency>
        <groupId>org.jboss.seam.international</groupId>
        <artifactId>seam-international</artifactId>
        <version>3.1.0.Final</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-api</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>solder-impl</artifactId>
                <groupId>org.jboss.solder</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Seam International precisa do joda-time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.1</version>
        <scope>compile</scope>
    </dependency>

    <!-- Seam Faces precisa do seam-transaction(mesmo que você não use para 
        nada) -->
    <dependency>
        <groupId>org.jboss.seam.transaction</groupId>
        <artifactId>seam-transaction</artifactId>
        <version>3.1.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-impl</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>jboss-servlet-api_3.0_spec</artifactId>
                <groupId>org.jboss.spec.javax.servlet</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Seam Faces precisa do seam-persistence(mesmo que você não use para 
        nada) -->
    <dependency>
        <groupId>org.jboss.seam.persistence</groupId>
        <artifactId>seam-persistence</artifactId>
        <version>3.1.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-impl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.transaction</groupId>
                <artifactId>seam-transaction</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.transaction</groupId>
                <artifactId>seam-transaction-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Seam Faces precisa do seam-security(mesmo que você não use para nada) -->
    <dependency>
        <groupId>org.jboss.seam.security</groupId>
        <artifactId>seam-security</artifactId>
        <version>3.1.0.Final</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.seam.persistence</groupId>
                <artifactId>seam-persistence</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.solder</groupId>
                <artifactId>seam-solder</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-impl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.international</groupId>
                <artifactId>seam-international-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.international</groupId>
                <artifactId>seam-international</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Seam Faces precisa do prettyfaces(mesmo que você não use para nada) -->
    <dependency>
        <groupId>com.ocpsoft</groupId>
        <artifactId>prettyfaces-jsf2</artifactId>
        <version>3.3.3</version>
        <scope>compile</scope>
    </dependency>

    <!-- Seam Faces precisa do drools(mesmo que você não use para nada) -->
    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>knowledge-api</artifactId>
        <version>5.4.0.Final</version>
        <scope>compile</scope>
    </dependency>

    <!-- Enfim, o Seam Faces -->
    <dependency>
        <groupId>org.jboss.seam.faces</groupId>
        <artifactId>seam-faces</artifactId>
        <version>3.1.0.Final</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.solder</groupId>
                <artifactId>solder-impl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.jboss.seam.international</groupId>
                <artifactId>seam-international-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Bean Validation Dependencies -->



    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.0.0.GA</version>
        <scope>compile</scope>
    </dependency>

    <!-- JPA Persistence Dependencies -->

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.0.Final</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
    </dependency>


    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.6</version>
    </dependency>

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.8.3</version>
    </dependency>

</dependencies>

<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.0.Beta1</version>
        </plugin>
    </plugins>
</build>

-------------------- Wildfly启动日志------------------------ --------------

at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:183) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:92) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:84) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:196) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_25]
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-security-manager-1.0.0.Final.jar:1.0.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]

------------------------------second error-----------------------------

 17:45:22,257 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."painel-teste.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."painel-teste.war".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
   Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
   Exception 0 :
   org.jboss.weld.exceptions.IllegalStateException: WELD-001332: BeanManager method getBeans() is not available during application initialization
    at org.jboss.weld.bean.builtin.BeanManagerProxy.checkContainerValidated(BeanManagerProxy.java:159)
    at org.jboss.weld.bean.builtin.BeanManagerProxy.getBeans(BeanManagerProxy.java:91)
    at org.jboss.solder.core.CoreExtension.failIfWeldExtensionsDetected(CoreExtension.java:215)
    at org.jboss.solder.core.CoreExtension.afterBeanDiscovery(CoreExtension.java:208)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
    at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:125)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:128)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:102)
    at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:63)
    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:35)
    at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:55)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:372)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:79)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:92)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:37)
    at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:55)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:372)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:79)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:92)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    ... 3 more

------------------------in the end say that some dependecies are missing-----

JBAS014775:    New missing/unsatisfied dependencies:
         service jboss.deployment.unit."painel-teste.war".WeldStartService (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."org.jboss.solder.servlet.event.ServletEventBridgeListener".WeldInstantiator, service jboss.deployment.unit."painel-teste.war".component."org.jboss.seam.faces.beanManager.BeanManagerServletContextListener".WeldInstantiator, service jboss.deployment.unit."painel-teste.war".component."com.sun.faces.taglib.jsf_core.CoreValidator".WeldInstantiator, service jboss.deployment.unit."painel-teste.war".component."com.sun.faces.taglib.jsf_core.ValueChangeListenerTag".WeldInstantiator, JBAS014799: ... and 49 more ] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.PrettyFilter".CREATE (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.PrettyFilter".START] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.PrettyFilter".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./painel-teste, service jboss.undertow.deployment.default-server.default-host./painel-teste.UndertowDeploymentInfoService, service jboss.deployment.unit."painel-teste.war".deploymentCompleteService] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.PrettyFilter".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.PrettyFilter".START] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.LinkTag".CREATE (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.LinkTag".START] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.LinkTag".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./painel-teste, service jboss.undertow.deployment.default-server.default-host./painel-teste.UndertowDeploymentInfoService, service jboss.deployment.unit."painel-teste.war".deploymentCompleteService] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.LinkTag".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.LinkTag".START] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.UrlBufferTag".CREATE (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.UrlBufferTag".START] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.UrlBufferTag".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./painel-teste, service jboss.undertow.deployment.default-server.default-host./painel-teste.UndertowDeploymentInfoService, service jboss.deployment.unit."painel-teste.war".deploymentCompleteService] 
         service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.UrlBufferTag".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."painel-teste.war".component."com.ocpsoft.pretty.faces.component.tag.UrlBufferTag".START] 

some more...

1 个答案:

答案 0 :(得分:2)

相当多的依赖项的范围不正确。您不应该对com.sun.faces:jsf-impl有依赖关系,而javax.faces:jsf-api应该标记为<scope>provided</scope>

所有Hibernate依赖项也应该标记为log4j和servlet依赖项。

org.wildfly.plugins:wildfly-maven-plugin现在版本为1.0.2.Final。