2016-02-05 64 views
1

我試圖將一個web項目(WEB-INF/lib中的所有JAR)遷移到maven web項目(pom.xml中的所有JAR)。NoClassDefFoundError:TomEE啓動時的javax/faces/component/UIViewAction

本項目採用以下庫:

  • JSF 2.2
  • PrimeFaces
  • BootsFaces
  • OmniFaces

它運行在TomEE。在TomEE啓動時出現,

以下錯誤:

NoClassDefFoundError: javax/faces/component/UIViewAction

但JSF2庫由TomEE提供類路徑。

這是我的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>[email protected]</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> 

感謝您的幫助。

回答

4

自從JSF 2.2以來,javax/faces/component/UIViewAction是新增的。因此你根本不使用JSF 2.2。您最有可能只使用JSF 2.1附帶的TomEE 1.x。

此問題由OmniFaces 2.2引發。它需要JSF 2.2。

你有2種選擇:

  1. 下調至2.1 OmniFaces。即使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發佈。最終版本預計在幾個月內。

+0

第二種方案效果很好。我在兩個項目中使用了「TomEE 7.0.0-M1」,使其具有JSF 2.2+,並且按預期工作。應該是@ludovic的有效解決方案Bernada – MWiesner

+0

你好,第二種選擇對我來說也適用。我應該花兩個小時尋找:)問:感謝BalusC的答案和MWiesner的測試。 –