Maven 2 com.sun.faces.config.ConfigurationException:不存在web.xml

Maven 2 com.sun.faces.config.ConfigurationException:不存在web.xml,maven-2,tomcat,jsf,web.xml,Maven 2,Tomcat,Jsf,Web.xml,我用JSF和其他一些Fraework编写了一个应用程序。然后我用maven销毁了元数据,然后创建了一个新项目,并将所有类和配置文件导入到新项目中。这样我就有了干净的元数据。这个项目现在可以顺利建成。但当我想在tomcat上启动它时,我得到了以下异常: com.sun.faces.config.ConfigurationException: no web.xml present at com.sun.faces.config.ConfigureListener$WebXmlProcessor.s

我用JSF和其他一些Fraework编写了一个应用程序。然后我用maven销毁了元数据,然后创建了一个新项目,并将所有类和配置文件导入到新项目中。这样我就有了干净的元数据。这个项目现在可以顺利建成。但当我想在tomcat上启动它时,我得到了以下异常:

com.sun.faces.config.ConfigurationException: no web.xml present
 at com.sun.faces.config.ConfigureListener$WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:785)
 at com.sun.faces.config.ConfigureListener$WebXmlProcessor.<init>(ConfigureListener.java:745)
 at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:173)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

更新2
  • 目录(在BalusC之后): 我找到了一本关于Maven Web项目的好手册。但不幸的是,问题依然存在。 我的目录结构如下所示:

更新3 对帕斯卡评论的回应:

  • mvn干净编译
    成功
  • mvn安装
    引发生成错误:

    [INFO]组装WAR时出错:需要webxml属性(如果在更新模式下执行,则需要预先存在的WEB-INF/WEB.xml)

我从windows控制台执行了这些命令


也许问题出在其他方面。启动服务器时出现另一个警告:

27.08.2010 09:04:52 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:studentportal' did not find a matching property.

也许这会有帮助?

一些提示。web.xml是否位于web-INF/web.xml

从源代码中,此特定异常被抛出:

InputStream in = context.getResourceAsStream(WEB_XML_PATH);
            if (in == null) {
                if (context.getMajorVersion() < 3) {
                    throw new ConfigurationException("no web.xml present");
                }
            }
因此它没有找到web.xml

出于某种原因,它期望Servlet3.0只在Tomcat7.0中可用,但我认为主要问题应该是web.xml的存在

最后,它还将在web.xml中查找定义的servlet,如下所示

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

Facesservlet
javax.faces.webapp.FacesServlet
1.

我开始了一个新项目,一次移动了一部分。在那之后它就开始工作了。不幸的是,我不知道问题出在哪里--


但是创建一个新的空项目并移动所有文件(配置文件除外,我再次编写了它们)是一种合理的方法。

您是否使用eclipse和m2eclipse插件?您能否显示项目的结构(没有
目标的
树的输出
)?问题是否可以重现?在
mvn清理编译之后
?有时候,m2eclipse并没有按照预期复制资源(这很烦人)。
private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>