2014-03-12 35 views
15

我嘗試了幾件事情,但仍然存在此問題。我正在使用Eclipse Kepler。我得到的導入Maven項目下面的錯誤JavaServer Faces 2.2需要動態Web模塊2.5或更新版本

的JavaServer Faces 2.2無法安裝:一個或多個約束沒有得到滿足

的JavaServer Faces 2.2需要動態Web模塊2.5或更高版本

1)我嘗試了Maven Java EE Configuration Marker with Java Server Faces 1.2中提到的幾件事,但沒有運氣。 2)此外,我進入.settings和修改org.eclipse.wst.common.project.facet.core.xml和修改jst.web指向2.5或3.0版本;但我收到了一些其他錯誤。

我想讓Sencha GXT的例子在基於http://neiliscoding.blogspot.ie/2012/05/how-to-setup-examples-for-use-in-gxt-3.html的maven/eclipse構建中工作,並讓這個javaserver在eclipse中面臨問題。 這裏是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<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/maven-v4_0_0.xsd"> 

<!-- POM file generated with GWT webAppCreator --> 
<modelVersion>4.0.0</modelVersion> 
<parent> 
    <artifactId>xx</artifactId> 
    <groupId>ss</groupId> 
    <version>0.0.1-SNAPSHOT</version> 
</parent> 

<artifactId>guis</artifactId> 
<packaging>war</packaging> 

<name>GWT Maven Archetype</name> 

<properties> 
    <!-- Convenience property to set the GWT version --> 
    <gwtVersion>2.5.1</gwtVersion> 
    <!-- GWT needs at least java 1.5 --> 
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>com.google.gwt.inject</groupId> 
     <artifactId>gin</artifactId> 
     <version>2.1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>7.0</version> 
    </dependency> 

    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-servlet</artifactId> 
     <version>${gwtVersion}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-user</artifactId> 
     <version>${gwtVersion}</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-dev</artifactId> 
     <version>${gwtVersion}</version> 
     <scope>provided</scope> 
    </dependency> 


    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.7</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
     <classifier>sources</classifier> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.sencha.gxt</groupId> 
     <artifactId>gxt-chart</artifactId> 
     <version>3.0.1</version> 
    </dependency> 

    <dependency> 
     <groupId>com.sencha.gxt</groupId> 
     <artifactId>gxt</artifactId> 
     <version>3.0.1</version> 
    </dependency> 

    <dependency> 
     <groupId>com.sencha.gxt</groupId> 
     <artifactId>uibinder-bridge</artifactId> 
     <version>2.4.0</version> 
    </dependency> 



</dependencies> 

<build> 
    <!-- Generate compiled stuff in the folder used for developing mode --> 
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> 

    <plugins> 

     <!-- GWT Maven Plugin --> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.5.1</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>compile</goal> 
         <goal>test</goal> 
         <!-- <goal>i18n</goal> --> 
         <goal>generateAsync</goal> 
        </goals> 
       </execution> 
      </executions> 
      <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
       documentation at codehaus.org --> 
      <configuration> 
       <runTarget>guis.html</runTarget> 
       <hostedWebapp>${webappDirectory}</hostedWebapp> 
       <i18nMessagesBundle>com.harmonia.client.Messages</i18nMessagesBundle> 
      </configuration> 
     </plugin> 

     <!-- Copy static web files before executing gwt:run --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <executions> 
       <execution> 
        <phase>compile</phase> 
        <!-- <goals> <goal>exploded</goal> </goals> --> 
       </execution> 
      </executions> 
      <configuration> 
       <webappDirectory>${webappDirectory}</webappDirectory> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

這裏是我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- <!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd"> 

<web-app> --> 

<web-app 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/web-app_3_0.xsd" 
        version="3.0"> 
<display-name>GXT Created Web Application</display-name> 



<!-- Default page to serve --> 
<welcome-file-list> 
    <welcome-file>guis.html</welcome-file> 
</welcome-file-list> 

正如你所看到的,我在上面的web.xml中嘗試不同的DTD ,但我仍然有問題。希望得到任何提示

回答

18

你的問題是,您標記你的web.xml爲Servlet 2.3的兼容(或者甚至沒有 - 我不知道你是如何在評論DOCTYPE解釋)

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- <!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd"> 

,並且您需要它至少符合servlet 2.5的要求才能使Eclipse工具正常工作。

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" 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/web-app_2_5.xsd"> 

(未經測試 - 從http://javahowto.blogspot.dk/2009/10/sample-webxml-servlet-25.html複製)

您可能需要重新創建Eclipse項目有變化回升。

+1

謝謝。在新的工作區重新創建幫助了我。試過maven更新和重新導入項目到同一工作區(但這些沒有幫助)幾件事情 –

+0

爲什麼當我這樣做時,我得到這個異常:java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer ??? –

+0

@It_Does_Not_Matter使用Glassfish。 –

18

我也遇到過Maven項目。這是我必須做的,以解決這個問題:

首先更新您的web.xml,如提到的ThorbjørnRavn Andersen。我使用低於3.0版本:

<web-app 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/web-app_3_0.xsd" 
         version="3.0"> 
    <display-name>Servlet 3.0 Web Application</display-name> 
</web-app> 

然後右鍵單擊您的項目,並選擇屬性 - >項目構面 在那裏你會看到你的動態Web模塊的版本。這需要從版本2.3或更改爲版本2.5或更高版本(我選擇3.0)。

但是要做到這一點,我不得不勾選動態Web模塊 - >應用的勾選框,然後對項目做一個Maven更新。回到Project Facets窗口,它應該已經匹配你的web.xml配置 - 在我的情況下是3.0。如果沒有,你應該可以改變它。

如果這不適用於您,請嘗試右鍵單擊Dynamic Web Module Facet並選擇更改版本(並確保它未鎖定)。

希望工程!

+0

感謝您發佈此解決方案。它也適用於我! 對於GWT開發者還有一個額外的警告:記住每當你調整eclipse對話框時,你的項目類路徑會重新變得混亂(eclipse執行它,M2Eclipse或者Mojo插件),你需要返回到你的項目「構建路徑」對話框(源選項卡)並確保以「../src/main/resources」結尾的條目具有「排除:(無)」,否則您的[module] .gwt.xml文件將再次變爲'unfindable'通過eclipse和東西將退出工作(即調試) – 2015-01-11 02:27:07

+0

:*這工作對我來說,並節省了我可能浪費時間的幾小時。另外,提示新來像我這樣的maven:更新Maven,右鍵單擊你的項目,尋找maven子菜單,在那裏,你會找到一個選項來運行更新('Update Project')。 – scottyseus

1

我自己的解決方案是將嚴格的依賴關係放在pom.xml中。

如果項目在構面中聲明爲3.1 Web動態項目,則java.servlet-api依賴項也必須是3.1.0(或3.1.x)版本。

在我來說,我已經離開了3.0.1版本,從而誘導在「問題」視圖此特定錯誤信息:

無法更改項目方面的動態Web模塊的版本爲3.0。 一個或多個約束尚未得到滿足。

(當然要確保你的web.xml也必須是3.1的)。

0

我的項目面臨同樣的問題。我改變了web.xml如下:

<web-app 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/web-app_3_0.xsd" 
        version="3.0"> 
<display-name>Archetype Created Web Application</display-name> 

的錯誤依然存在。但在遵循以下鏈接提出的建議後,問題就解決了。

http://crunchify.com/how-to-fix-cannot-change-version-of-project-facet-dynamic-web-module-to-3-0-error-in-eclipse/

0

**打開項目的pom.xml,並添加這個插件標籤 最後,右鍵點擊你的項目>的Maven>更新項目...

<build> 
<plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>3.1</version> 
    <configuration> 
     <source>1.7</source> 
     <target>1.7</target> 
    </configuration> 
</plugin> 
</plugins> 

**

0

我遇到這個問題以及ThorbjørnRavn Andersen的回答沒有幫助,因爲我已經在Dynamic Web Module 2.5。幾年前我遇到過同樣的問題並放棄了。決定重新調查我第一次做的是嘗試取消對「Dynamic Web Module」的支持 - 但是,嘿,它被鎖定了?所以我解鎖它並禁用/取消選中它。然後我解鎖了JavaServer Faces,取消選中它,點擊應用 - 不爆炸!然後用手指交叉,然後重新選中Dynamic Web Module並將其設置爲3.1。然後我重新檢查了JavaServer Faces將其設置爲2.2。點擊申請 - 沒有「大badda繁榮」,它工作 - 利潤!希望這可以幫助有相同問題的其他人,也不依賴於調整XML文件。

注意我也沒有將java分面版本設置爲1.8以及它是必需的。

0

我有同樣的問題,並在我的web.xml有版本2.5,而項目(右鍵單擊項目 - >屬性 - > Progect Facets->)動態Web模塊2.3。雖然我試圖將版本從2.3更改爲2.5,但ECLIPSE不允許。

Solution:我刪除了標題Dynamic Web Module下的複選標記,我保存了並且有了Update Project。自動重新喚醒正在輸入正確版本的包裝盒。

0

,我已經找到了解決這一問題的解決方案是

1)右鍵單擊項目>屬性>取消選中動態Web模塊>應用,然後關閉。

2)右鍵單擊Project> Maven> Update Project ...

0

試試這個: 在Eclipse中刪除您的項目。刪除Eclipse項目,而不是你的應用程序!它應該從項目列表中消失。 在Windows資源管理器中找到您的項目目錄並刪除目錄.settings和target(如果找到)並刪除文件.project和.classpath。 回到Eclipse,導入現有的Maven項目。就這些!

假設你的web.xml有正確的頭文件< web-app >到你的目標JSF版本。

相關問題