Search code examples
eclipsejsfwebsphereweb.xml

JSF projects in Eclipse not working with Websphere


I am new to JSF, so I am trying to develop simple JSF project in Eclipse using Websphere 8, but I am getting the following error:

Error 404: com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException: No target servlet configured for uri: /KeyValue/index.jsf 

I observed that when I add the following jars I get this 404 Error.

  1. jsf-api
  2. jsf-impl
  3. jstl-api-1.2
  4. jstl-impl-1.2

Here's how my web.xml looks:

<?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" version="2.5">
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
      <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
    </web-app>

Is there something wrong with the web.xml file? How do I resolve the issue?


Solution

  • Websphere ships as being a full fledged Java EE application server already with JSF and JSTL out the box. You do not need to provide them along your web application like as necessary when targeting a barebones servletcontainer such as Tomcat or Jetty. Those problems are most likely caused by version incompatibility between the JSF JARs provided by Websphere and the JSF JARs provided by the webapp, causing among others the FacesServlet to fail to start. Without a functioning FacesServlet, the *.jsf URLs will not be recognized anymore and thus end up as 404. More detail about the FacesServlet startup problem should however have been visible in the webapp's startup logs in the server.

    So, remove those JSF and JSTL JARs from your web application and it should work as expected.