eclipse JavaServer Faces 2.2 需要动态 Web 模块 2.5 或更新版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22361005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:02:53  来源:igfitidea点击:

JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer

eclipsemavenjsfconfiguration

提问by kashili kashili

I tried few things, but still this problem persists. I am using Eclipse Kepler. I get following error on importing maven project

我尝试了几件事,但这个问题仍然存在。我正在使用 Eclipse 开普勒。我在导入 maven 项目时遇到以下错误

JavaServer Faces 2.2 can not be installed : One or more constraints have not been satisfied

JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer

无法安装 JavaServer Faces 2.2 : 一个或多个约束没有得到满足

JavaServer Faces 2.2 需要动态 Web 模块 2.5 或更新版本

1) I tried few things as mentioned in Maven Java EE Configuration Marker with Java Server Faces 1.2, but no luck. 2)Also I went into .settings and modified org.eclipse.wst.common.project.facet.core.xml and modified jst.web to point to 2.5 or 3.0 version; but I get some other errors.

1)我尝试了Maven Java EE Con​​figuration Marker with Java Server Faces 1.2 中提到的一些事情,但没有运气。2)我也进入.settings并修改org.eclipse.wst.common.project.facet.core.xml和修改jst.web指向2.5或3.0版本;但我遇到了一些其他错误。

I am trying to make Sencha GXT examples work in maven/eclipse build based on http://neiliscoding.blogspot.ie/2012/05/how-to-setup-examples-for-use-in-gxt-3.htmland having this javaserver faces problem in eclipse. Here is my pom.xml

我试图使 Sencha GXT 示例在基于http://neiliscoding.blogspot.ie/2012/05/how-to-setup-examples-for-use-in-gxt-3.html和在 Eclipse 中使用这个 javaserver 会遇到问题。这是我的 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>

Here is my web.xml file

这是我的 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>

As you can see, I tried different dtds in above web.xml, but I still have the problem. Would appreciate any hints

如您所见,我在上面的 web.xml 中尝试了不同的 dtds,但问题仍然存在。希望得到任何提示

回答by raghera

I have encountered this with Maven projects too. This is what I had to do to get around the problem:

我在 Maven 项目中也遇到过这个问题。这是我必须做的来解决这个问题:

First update your web.xml as mentioned Thorbj?rn Ravn Andersen. I used version 3.0 as below:

首先更新您的 web.xml 如上所述 Thorbj?rn Ravn 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>

Then right click on your project and select Properties -> Project Facets In there you will see the version of your Dynamic Web Module. This needs to change from version 2.3 or whatever to version 2.5 or above (I chose 3.0).

然后右键单击您的项目并选择 Properties -> Project Facets 在那里您将看到您的动态 Web 模块的版本。这需要从 2.3 版或其他版本更改为 2.5 版或更高版本(我选择了 3.0)。

However to do this I had to uncheck the tick box for Dynamic Web Module -> Apply, then do a Maven Update on the project. Go back into the Project Facets window and it should already match your web.xml configuration - 3.0 in my case. You should be able to change it if not.

但是,要做到这一点,我必须取消选中 Dynamic Web Module -> Apply 的复选框,然后对项目进行 Maven 更新。返回 Project Facets 窗口,它应该已经与您的 web.xml 配置相匹配 - 在我的情况下为 3.0。如果没有,您应该能够更改它。

If this does not work for you then try right-clicking on the Dynamic Web Module Facet and select change version (and ensure it is not locked).

如果这对您不起作用,请尝试右键单击 Dynamic Web Module Facet 并选择更改版本(并确保它没有被锁定)。

Hope that works!

希望有效!

回答by Thorbj?rn Ravn Andersen

Your problem is that you have marked your web.xml as being servlet 2.3 compliant (or perhaps not even that - I am not sure how your doctype in a comment is interpreted)

您的问题是您已将您的 web.xml 标记为符合 servlet 2.3(或者甚至可能不是 - 我不确定您在评论中的文档类型是如何解释的)

 <?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">

and you need it to be at least servlet 2.5 compliant for the Eclipse tooling to work.

并且您需要它至少与 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">

(untested - copied from http://javahowto.blogspot.dk/2009/10/sample-webxml-servlet-25.html)

(未经测试 - 从http://javahowto.blogspot.dk/2009/10/sample-webxml-servlet-25.html复制)

You may need to recreate the Eclipse project to have the changes picked up.

您可能需要重新创建 Eclipse 项目以获取更改。

回答by Piyush Mittal

I had the same problem and in my web.xml had version 2.5 while the project had the (right-click on Project-> Properties-> Progect Facets->) Dynamic Web Module 2.3. Although I tried to change the version from 2.3 to 2.5 ECLIPSE did not permit it.

我有同样的问题,在我的 web.xml 中有 2.5 版,而项目有(右键单击 Project-> Properties-> Progect Facets->)Dynamic Web Module 2.3。尽管我尝试将版本从 2.3 更改为 2.5,但 ECLIPSE 不允许。

Solution:I removed the check mark under the heading Dynamic Web Module, I saved and I had Update Project. Automatically re-awakening is entering the box with the correct version.

Solution:我删除了标题动态 Web 模块下的复选标记,我保存并更新了项目。自动重新唤醒是输入正确版本的框。

回答by Piyush Mittal

The solution that i had found for this problem is

我为这个问题找到的解决方案是

1 ) Right Click on the Project >Properties>Uncheck Dynamic Web Module>Apply And Close.

1 ) 右键单击​​项目>属性>取消选中动态Web模块>应用并关闭。

2 ) Right Click on the Project>Maven>Update Project...

2)右键单击项目>Maven>更新项目...

回答by Elizabeth Bradley

My project was facing the same issue. I changed the web.xml as follows:

我的项目面临同样的问题。我更改了 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>

The error persisted. But after following the suggestions made in the following link, the issue was resolved.

错误仍然存​​在。但是在遵循以下链接中提出的建议后,问题得到了解决。

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

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

回答by JoseA

Try this : Delete your project in Eclipse. Delete the Eclipse project, not your application! It should disappear from the list of projects. In Windows Explorer locate your project directory and delete the directories .settings and target (if found) and delete the files .project and .classpath. Back to Eclipse, import existing Maven project. That is all!

试试这个:在 Eclipse 中删除您的项目。删除 Eclipse 项目,而不是您的应用程序!它应该从项目列表中消失。在 Windows 资源管理器中,找到您的项目目录并删除目录 .settings 和 target(如果找到)并删除文件 .project 和 .classpath。回到 Eclipse,导入现有的 Maven 项目。就这些!

Assuming that your web.xml has the right header <web-app> to your target JSF version.

假设您的 web.xml 具有正确的标题 <web-app> 到您的目标 JSF 版本。

回答by LAURENT CHRETIEN

My own solution was to put the rignt dependency in the pom.xml.

我自己的解决方案是将 rignt 依赖项放在 pom.xml 中。

If the project is declared as a 3.1 Web Dynamic Project in the facets, then the java.servlet-api dependency also has to be the 3.1.0 (or 3.1.x) version.

如果项目在 facet 中声明为 3.1 Web 动态项目,则 java.servlet-api 依赖项也必须是 3.1.0(或 3.1.x)版本。

In my case I had left 3.0.1 version, thus inducing this specific error message in the "Problems" view :

在我的情况下,我离开了 3.0.1 版本,从而在“问题”视图中引入了这个特定的错误消息:

Cannot change version of project facet Dynamic Web Module to 3.0. One or more constraints have not been satisfied.

无法将项目方面动态 Web 模块的版本更改为 3.0。一个或多个约束条件尚未满足。

(of course make sure in addition that your web.xml must also be the 3.1 one).

(当然还要确保你的 web.xml 也必须是 3.1 的)。

回答by Falco

For me none of previous worked.

对我来说,以前都没有工作。

Then I found this link: https://crunchify.com/how-to-fix-cannot-change-version-of-project-facet-dynamic-web-module-to-3-0-error-in-eclipse/

然后我找到了这个链接:https: //crunchify.com/how-to-fix-cannot-change-version-of-project-facet-dynamic-web-module-to-3-0-error-in-eclipse/

for me was almost the same as described in that link.

对我来说几乎与该链接中描述的相同。

  • Go to your Eclipse Workspace location
  • Open file /.settings/org.eclipse.wst.common.project.facet.core.xml.
  • Modify version for jst.web property to 2.5
  • Back in eclipse
  • Right click on Project
  • Refresh
  • Click on Project
  • Select Clean
  • Right-click on project name
  • Click on Maven
  • Update project
  • 转到您的 Eclipse 工作区位置
  • 打开文件 /.settings/org.eclipse.wst.common.project.facet.core.xml。
  • 将 jst.web 属性的版本修改为 2.5
  • 回到日食
  • 右键单击项目
  • 刷新
  • 点击项目
  • 选择清洁
  • 右键单击项目名称
  • 单击 Maven
  • 更新项目

Problems gone for me

我的问题消失了

回答by Zakaria Abdi

I had the same error and I have solved as following:

我有同样的错误,我已经解决如下:

STEP 1:Update web.xml file, and add the following codes

STEP 1:更新web.xml文件,并添加以下代码

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
</web-app>

STEP 2: Write click on the project folder, and select Propertiesthen search "Project Facets". You need to uncheck "Dynamic Web Module", then Apply and then close it. See Eclipse properties

STEP 2: 点击项目文件夹,选择属性,然后搜索“Project Facets”。您需要取消选中“动态 Web 模块”,然后应用并关闭它。 查看 Eclipse 属性

STEP 3: Update your Maven, then you good to go.

第 3步:更新您的 Maven,然后您就可以开始了。

回答by VEMM

I follow the next steps.

我按照以下步骤操作。

Right click on project -> Properties -> Project Facets. Mark Dynamic Web Module, JavaServer Facesand choose the versions of your project. (If you get the message Cannot change version of project facet Dynamic Web Modulefollow the next tutorial How to fix Cannot change version of project facet Dynamic Web Module)

右键单击 project -> Properties -> Project Facets。标记Dynamic Web ModuleJavaServer Faces并选择项目的版本。(如果您收到消息无法更改项目构面动态 Web 模块的版本,请按照下一个教程如何修复无法更改项目构面动态 Web 模块的版本

Delete the web.xmlfile, then right click on project -> Java EE Tools -> Generate Deployment Descriptor Stub.

删除web.xml文件,然后右键单击 project -> Java EE Tools -> Generate Deployment Descriptor Stub

Delete the project from eclipse (don't delete the sources), then at the project root level execute:

从 Eclipse 中删除项目(不要删除源),然后在项目根级别执行:

mvn eclipse:clean
mvn eclipse:eclipse
mvn clean install -X

Import the project again as Existing Maven Projects.

再次将项目作为Existing Maven Projects导入。

My web.xml looks like this:

我的 web.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">
    <display-name>jsf-sample</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>