com.sun.faces.config.ConfigurationException: no web.xml present
I programmed an application with JSF and some other fraeworks. Then I destroyed my metadata with maven and then I created a new project and imported all my classes and config files into the new project. So that I have clean metadata. The Project can be built without problems now. But when I want to start it onto tomcat I get the following exception:
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.Ca开发者_JS百科talina.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)
But there is definitely a web.xml
in that project. Has somebody an idea where my mistake could be? Thank you
Update
Yes I am using m2Eclipse!
My directory tree looks like:
OLD
My Servlet is there as well:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
UPDATE2
- Directories (after BalusC Commend): Here I have found a good Manual about Maven Web Projects. But unfortunately the problem stayed the same. My directory structure looks like:
UPDATE3
Response to Pascal's comment:
mvn clean compile
is successfullmvn install
throws a build error:[INFO] Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if execut ing in update mode)
I executed those commands from windows console
Maybe the problem is something else. There is another Warning while starting the server:
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.
Maybe that helps?
Some pointers. Is the web.xml placed at WEB-INF/web.xml ?
From the source code, this particular exception is thrown at:
InputStream in = context.getResourceAsStream(WEB_XML_PATH);
if (in == null) {
if (context.getMajorVersion() < 3) {
throw new ConfigurationException("no web.xml present");
}
}
and it's looking for web.xml at
private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
So it did not find the web.xml.
Also for some reason it's expecting Servlet 3.0 which is only available with Tomcat 7.0 - but I think the main issue should be the presence of web.xml
Finally, it will also be looking for the defined servlet in the web.xml like below
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
I started a new project and moved one part at once. After that it works. Unfortunately I have no idea where the problem was -.-
But creating a new empty project and moving all the files (except config files, I wrote them again) is a reasonable approach..
精彩评论