1

我尝试使用 Maven TomEE 插件在我的 webapp 上执行mvn tomee:start ,但出现以下异常:

INFO: Initializing Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0@11930) for context '/glue'
Sep 25, 2013 7:18:08 PM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment: 
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.application.ApplicationFactory' was not configured properly.
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:330)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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)
Caused by: javax.faces.FacesException: org.apache.webbeans.jsf.OwbApplicationFactory
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:710)
    at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:572)
    at javax.faces.FactoryFinder.access$500(FactoryFinder.java:140)
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1120)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
    ... 16 more
Caused by: com.sun.faces.spi.InjectionProviderException: org.apache.webbeans.exception.WebBeansConfigurationException: No constructor is found for the class : org.apache.webbeans.jsf.OwbApplicationFactory
    at org.apache.tomee.mojarra.TomEEInjectionProvider.inject(TomEEInjectionProvider.java:41)
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:695)
    ... 21 more
Caused by: org.apache.webbeans.exception.WebBeansConfigurationException: No constructor is found for the class : org.apache.webbeans.jsf.OwbApplicationFactory
    at org.apache.webbeans.util.WebBeansUtil.defineConstructor(WebBeansUtil.java:489)
    at org.apache.webbeans.util.WebBeansUtil.defineConstructor(WebBeansUtil.java:457)
    at org.apache.openejb.cdi.ConstructorInjectionBean.<init>(ConstructorInjectionBean.java:47)
    at org.apache.openejb.core.WebContext.inject(WebContext.java:151)
    at org.apache.tomee.catalina.JavaeeInstanceManager.inject(JavaeeInstanceManager.java:84)
    at org.apache.tomee.mojarra.TomEEInjectionProvider.inject(TomEEInjectionProvider.java:39)
    ... 22 more

Sep 25, 2013 7:18:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 25, 2013 7:18:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/glue] startup failed due to previous errors
Sep 25, 2013 7:18:09 PM javax.faces.FactoryFinder$FactoryManager getFactory
SEVERE: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory. Attempting to find backup.
Sep 25, 2013 7:18:09 PM com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory. 
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1135)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:140)
    at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:310)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4837)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5483)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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)

Sep 25, 2013 7:18:09 PM org.apache.openejb.assembler.classic.Assembler destroyApplication

...然后我的应用程序立即从容器中取消部署。请注意,当我从 Eclipse 启动 TomEE 时,我没有任何问题,而且我的 web 应用程序运行良好。

这是我的POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>foo-webapp</artifactId>
    <packaging>war</packaging>

    <parent>
        <groupId>com.foo</groupId>
        <artifactId>foo-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <build>
        <finalName>foo</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.openejb.maven</groupId>
                <artifactId>tomee-maven-plugin</artifactId>
                <version>1.0.1</version>
                <configuration>
                    <tomeeVersion>1.5.2</tomeeVersion>
                    <tomeeClassifier>webprofile</tomeeClassifier>
                    <config>${project.basedir}/src/main/webapp/META-INF/conf</config>
                    <libs>
                        <lib>mysql:mysql-connector-java:${mysql.version}</lib>
                    </libs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <jersey.version>1.17</jersey.version>
        <mysql.version>5.1.26</mysql.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.foo</groupId>
            <artifactId>foo-data-model</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.0.13</version>
        </dependency>
        <!-- RESTful Web Services -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <!-- JSON support -->
        <!-- Use GsonMessageBodyHandler instead -->
        <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> 
            <version>${jersey.version}</version> </dependency> -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>${jersey.version}</version>
        </dependency>
    </dependencies>

</project>

我实际上还没有使用 CDI,并且我的 beans.xml 在 WEB-INF/ 目录下是空的:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd" />

那么,我是否在某处遗漏了什么?

4

0 回答 0