问题
I'm trying to migrate a web project (all JARs in WEB-INF/lib
) to a maven web project (all JARs in pom.xml
).
This project uses following libraries:
- JSF 2.2
- PrimeFaces
- BootsFaces
- OmniFaces
It runs on TomEE.
The following error appears on TomEE startup:
NoClassDefFoundError: javax/faces/component/UIViewAction
But JSF2 library is provided by TomEE on classpath.
Here is my 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>
Thanks for your help.
回答1:
The class javax/faces/component/UIViewAction is new since JSF 2.2. You're thus not using JSF 2.2 at all. You're most likely using only TomEE 1.x, which ships with JSF 2.1.
This problem is triggered by OmniFaces 2.2. It requires JSF 2.2.
You have 2 options:
Downgrade to OmniFaces 2.1. Even though OmniFaces 2.x officially requires JSF 2.2, OmniFaces versions 2.0 and 2.1 do not have deploy time JSF 2.2 dependencies. OmniFaces version 2.2 was with
<o:viewAction>
tag the first version to require JSF 2.2 during deploy time.Upgrade to TomEE 7.x, the first version to implement Java EE 7 and thus inherently JSF 2.2. It's currently only available as M1 release. Final release is expected within months.
来源:https://stackoverflow.com/questions/35226794/noclassdeffounderror-javax-faces-component-uiviewaction-on-tomee-startup