2017-08-10 79 views
0

我正在开发一个JSF 2.2应用程序,它已部署到我的本地apache tomcat 7中。部署的WAR在Apache Tomcat上显示404 7

tomcat日志显示在部署中一切正常,但是当我指向路径时,我得到了404。

在apache web admin上显示应用程序正在运行。

我从零创建项目没有任何ide,文件结构是标准的maven webapp结构。

ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig undeploy 
INFORMACIËN: Repliegue (undeploy) de la aplicaci¾n web que tiene como trayectori 
a de contexto /hello1-1.0 
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig deployWAR 
INFORMACIËN: Despliegue del archivo C:\Apache\apache-tomcat-7.0.68-windows-x64\a 
pache-tomcat-7.0.68\webapps\hello1-1.0.war de la aplicaci¾n web 
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.TldConfig execute 
INFORMACIËN: At least one JAR was scanned for TLDs yet contained no TLDs. Enable 
debug logging for this logger for a complete list of JARs that were scanned but 
no TLDs were found in them. Skipping unneeded JARs during scanning can improve 
startup time and JSP compilation time. 
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig deployWAR 
INFORMACIËN: Deployment of web application archive C:\Apache\apache-tomcat-7.0.6 
8-windows-x64\apache-tomcat-7.0.68\webapps\hello1-1.0.war has finished in 297 ms 

这里是我的pom.xml

<project> 
<groupId>com.lol</groupId> 
<artifactId>hello1</artifactId> 
<version>1.0</version> 
<modelVersion>4.0.0</modelVersion> 
<packaging>war</packaging> 
<dependencies> 
    <dependency> 
     <groupId>javax.enterprise</groupId> 
     <artifactId>cdi-api</artifactId> 
     <version>2.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.faces</groupId> 
     <artifactId>javax.faces-api</artifactId> 
     <version>2.2</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.logging.log4j</groupId> 
     <artifactId>log4j-api</artifactId> 
     <version>2.8.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.logging.log4j</groupId> 
     <artifactId>log4j-core</artifactId> 
     <version>2.8.2</version> 
    </dependency> 
</dependencies> 
<properties> 
    <maven.compiler.source>1.8</maven.compiler.source> 
    <maven.compiler.target>1.8</maven.compiler.target> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 
<build> 
    <filters> 
     <filter>src/env/${env}.properties</filter> 
    </filters> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
      <filtering>true</filtering> 
     </resource> 
    </resources> 
    <testResources> 
     <testResource> 
      <directory>src/test/resources</directory> 
      <filtering>true</filtering> 
     </testResource> 
    </testResources> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.2</version> 
      <configuration> 
       <webXml>src/webapp/WEB-INF/web.xml</webXml> 
       <outputDirectory>C:\Apache\apache-tomcat-7.0.68-windows-x64\apache-tomcat-7.0.68\webapps</outputDirectory> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 
<profiles> 
    <profile> 
     <id>dev</id> 
     <properties> 
      <env>dev</env> 
     </properties> 
     <activation> 
      <activeByDefault>true </activeByDefault> 
     </activation> 
    </profile> 
    <profile> 
     <id>qa</id> 
     <properties> 
      <env>qa</env> 
     </properties> 
    </profile> 
    <profile> 
     <id>preprod</id> 
     <properties> 
      <env>preprod</env> 
     </properties> 
    </profile> 
    <profile> 
     <id>prod</id> 
     <properties> 
      <env>prod</env> 
     </properties> 
    </profile> 
</profiles> 

而且我的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 

    <display-name>Hello1</display-name> 

    <!-- Change to "Production" when you are ready to deploy --> 
    <context-param> 
     <param-name>javax.faces.PROJECT_STAGE</param-name> 
     <param-value>Development</param-value> 
    </context-param> 

    <!-- Welcome page --> 
    <welcome-file-list> 
     <welcome-file>index.xhtml</welcome-file> 
    </welcome-file-list> 

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

    <!-- Map these files with JSF --> 
    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.xhtml</url-pattern> 
    </servlet-mapping> 

</web-app> 

我的索引

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> 
<h:head> 
    <title>Facelets Hello Greeting</title> 
</h:head> 
<h:body> 
    <h:form> 
     <h:graphicImage url="#{resource['images:duke.waving.gif']}" alt="Duke waving his hand" /> 
     <h2>Hello, my name is Duke. What's yours?</h2> 
     <h:inputText id="username" title="My name is: " value="#{hello.name}" required="true" requiredMessage="Error: A name is required." 
      maxlength="25" /> 
     <p></p> 
     <h:commandButton id="submit" value="Submit" action="response"> 
     </h:commandButton> 
     <h:commandButton id="reset" value="Reset" type="reset"> 
     </h:commandButton> 
    </h:form> 
</h:body> 

</html> 
+0

您能否显示您的项目的目录布局?在你的POM中有'src/webapp/WEB-INF/web.xml'条目,但是按照[maven标准目录布局](https://maven.apache.org/guides/introduction/introduction-to-the- standard-directory-layout.html),'WEB.xml'文件应该放在'src/main/webapp/WEB-INF/web.xml'中,但不要放在'src/webapp/....'子目录下。你为什么不在你的项目中使用[Tomcat 7 Maven plugin](http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/)? – krokodilko

+0

你说得对,我改变了布局 – user2565755

回答

0

我使用了glassfish服务器,并改变了java-ee-api依赖关系的依赖关系,并像魅力一样工作。