This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 70952

Summary: A web project created with a JSF support fails to run the Faces Servlet
Product: javaee Reporter: Libor Kotouc <lkotouc>
Component: JSFAssignee: Petr Pisl <ppisl>
Status: RESOLVED FIXED    
Severity: blocker CC: bleonard
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Error page content

Description Libor Kotouc 2006-01-03 16:20:53 UTC
1. create a web project with JSF framework support
2. run it and wait until index.jsp is shown in a browser
3. click at the link "Java Server Faces Welcome Page"

Error page is shown - see attachment.

NB060102, JBoss4.0.3SP1, JDK1.5.0_02, JSF1.1 libraries (bundled in the WAR files
by NetBeans)
Comment 1 Libor Kotouc 2006-01-03 16:23:44 UTC
Created attachment 28154 [details]
Error page content
Comment 2 Libor Kotouc 2006-01-06 13:21:32 UTC
Fixable in 5.1
Comment 3 ajacobs3 2006-06-02 18:41:48 UTC
In NB IDE
  File=>New Project
In New Project dialog
  Web=>Web Application
  Next>
  Project Name (AllJSPJSF)
  Source Structure: Java BluePrints
  Server: Bundled Tomcat (5.5.9)
  Context Path: /AllJSPJSF
  X Set Source Level to 1.4
    Set as Main Project                   (unset)
  Next>
  X Java Server Faces
    Struts 1.2.7                          (unset)
  Next>
  Servlet URL Mapping: /faces/*
  X Validate XML
    Verify Objects                        (unset)
  Finish
The file AllJSPStruts/web/WEB-INF/web.xml will not validate.
There are two XML nodes for the servlet "Faces Servlet".
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
Comment 4 ajacobs3 2006-06-03 02:31:36 UTC
There were more duplicate entries in web.xml.  <servlet-mapping> was duplicated.
The <context-param> nodes for com.sun.faces.verifyObjects, 
com.sun.faces.validateXml, javax.faces.CONFIG_FILES, and
javax.faces.STATE_SAVING_METHOD were triplicated.  Fixing these errors, I
managed to generate an application that was deployable in Tomcat.  Then, I got
the error that is in this bug report.  The log contains the entry

Jun 2, 2006 6:14:35 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find FacesContext
        at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405)

faces-config.xml is still empty and this may not be legitimate.
<faces-config>  
</faces-config>

Comment 5 ajacobs3 2006-06-07 06:59:43 UTC
Regenerated the JSF.  No duplicates seen, so ignore the comments in my
previous post.  The web.xml looks valid.  But it is not.
The generated code is wrong in two places.

The fix for this bug involves changes to both index.jsp and web.xml.

In index.jsp, the anchor
   <a href="./faces/welcomeJSF.jsp">Java Server Faces Welcome Page</a>
should read
   <a href="/WebApp/welcomeJSF.faces">Java Server Faces Welcome Page</a>
In web.xml, the servlet mapping for "Faces Servlet" is
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>faces/*</url-pattern>
    </servlet-mapping>
and should be
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
Comment 6 Libor Kotouc 2006-06-07 13:02:00 UTC
The servlet mapping is correct. welcomeJSF.jsp is referenced from the index.jsp
as /faces/welcomeJSF, thus /faces/* pattern is recognized and the Faces Servlet
is used. Of course '*.faces' way of mapping works also well.

There are two ways how to solve the exception.
1/ remove jbossweb-tomcat55.sar/jsf-libs directory, i.e. the server does not use
MyFaces, instead of it JSF libraries bundled with the Web module are used

2/ IDE mustn't package the JSF and JSTL libraries into the Web module and
<listener>       
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>    

must be added into the web.xml.

The second way will be used to fix this bug. Reassining to 'JSF' module.
Comment 7 Libor Kotouc 2006-06-07 15:39:16 UTC
*** Issue 76733 has been marked as a duplicate of this issue. ***
Comment 8 Libor Kotouc 2006-06-07 15:40:03 UTC
*** Issue 74392 has been marked as a duplicate of this issue. ***
Comment 9 Petr Pisl 2006-08-09 09:56:58 UTC
Already fixed.