0

I am developing a JSF 2.2 app and it has been deployed into my local apache tomcat 7 .

The tomcat log shows everything is ok on the deployment but I get a 404 once I point to the path.

On the apache web admin shows the app running.

I am creating the project from zero without any ide , the file structure is the standard maven webapp structure .

 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

Here is my 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>

And my 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>

my index

     <!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>
jcromanu
  • 1,171
  • 2
  • 13
  • 31
  • Could you show a directory layout of your project ? There is `src/webapp/WEB-INF/web.xml` entry in your POM, but accorrding to [maven standard directory layout](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html), `WEB.xml` file should be placed in `src/main/webapp/WEB-INF/web.xml` but not in `src/webapp/....` subdirectory. Why don't you use [Tomcat 7 Maven plugin](http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/) in your project ? – krokodilko Aug 13 '17 at 05:20
  • You are right in your observation I changed the layout – jcromanu Aug 17 '17 at 21:40

1 Answers1

0

I used a glassfish server and changed the faces dependency for the java-ee-api dependency and works like a charm .

jcromanu
  • 1,171
  • 2
  • 13
  • 31