NoClassDefFoundError:TomEE启动时的javax / faces / component / UIViewAction

时间:2016-02-05 14:40:33

标签: maven jsf tomee omnifaces tomee-7

我正在尝试将一个Web项目(WEB-INF/lib中的所有JAR)迁移到maven Web项目(pom.xml中的所有JAR)。

该项目使用以下库:

  • JSF 2.2
  • PrimeFaces
  • BootsFaces
  • OmniFaces

它在TomEE上运行。

TomEE启动时出现以下错误:

  

NoClassDefFoundError:javax / faces / component / UIViewAction

但是,TomF在类路径上提供了JSF2库。

这是我的pom.xml

<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>
<groupId>com.lb</groupId>
<artifactId>XXX</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>XXX</name>
<description>Application XXX</description>

<url>http://XXX.fr</url>
<organization>
    <name>XXX</name>
    <url>http://XXX.fr</url>
</organization>
<inceptionYear>2016</inceptionYear>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <javase.version>1.7</javase.version>
    <javaee.version>7.0</javaee.version>
</properties>

<developers>
    <developer>
        <id>XXX</id>
        <name>YYY</name>
        <email>ZZZ@gmail.com</email>
    </developer>
</developers>

<build>
    <directory>${basedir}/target/${project.artifactId}-${project.version}</directory>
    <finalName>XXX</finalName>

    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.java</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${javase.version}</source>
                <target>${javase.version}</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resource>
                    <resource>
                        <directory>${basedir}/src/main/resources</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF/resources</targetPath>
                    </resource>
                </webResources>
                <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
                <packagingExcludes>
                    **/*.java,
                </packagingExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.3</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.10</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>bootstrap</artifactId>
        <version>1.0.10</version>
    </dependency>

    <dependency>
        <groupId>net.bootsfaces</groupId>
        <artifactId>bootsfaces</artifactId>
        <version>0.8.1</version>
    </dependency>
    <dependency>
        <groupId>org.omnifaces</groupId>
        <artifactId>omnifaces</artifactId>
        <version>2.2</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>prime-repo</id>
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
        <layout>default</layout>
    </repository>
</repositories>

感谢您的帮助。

1 个答案:

答案 0 :(得分:4)

自{JSF 2.2}以来,类javax/faces/component/UIViewAction是新的。因此,您根本不使用JSF 2.2。您最有可能只使用随IBM JS 2.1一起提供的TomEE 1.x.

此问题由OmniFaces 2.2触发。它需要JSF 2.2。

您有两个选择:

  1. 降级为OmniFaces 2.1。即使OmniFaces 2.x正式requires JSF 2.2,OmniFaces版本2.0和2.1也没有部署时间JSF 2.2依赖项。 OmniFaces 2.2版带有<o:viewAction>标记在部署期间需要JSF 2.2的第一个版本。

  2. 升级到TomEE 7.x,这是实现Java EE 7的第一个版本,因此也就是JSF 2.2。目前只有available作为M1发布。预计最终版本将在几个月内发布。