facebook

NullPointerException when trying to load JSF application

  1. MyEclipse Archived
  2.  > 
  3. Web Development (HTML, CSS, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #243134 Reply

    efratb
    Member

    Hi,

    I’m new with JSF and I’m trying to create my first jsf-service application using myeclipse.
    I followed the first steps of the tutorial, but I have a NullPointerException when trying to use a JSF tag in my file.

    My web.xml is defined as follows:
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    </web-app>

    And faces-config.xml:
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE faces-config PUBLIC
    “-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN”
    http://java.sun.com/dtd/web-facesconfig_1_1.dtd”&gt;

    The exception that I get is:

    java.lang.NullPointerException
    javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:615)
    javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:217)
    org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:71)
    (HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

    I guess that it’s a matter of configuration, but couldn’t find a solution.
    Can someone help?

    Thanks,
    Efrat

    #243205 Reply

    Riyad Kalla
    Member

    Efrat,
    What is the entire stack trace? Sometimes the real problem is farther down.

    Also what URL are you using to get at your page? Are you trying to use a .jsp extension or .faces extension?

    #243301 Reply

    efratb
    Member

    Hi,

    My entire stack:

    exception

    org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

    root cause

    java.lang.NullPointerException
    javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:615)
    javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:217)
    org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:71)
    org.apache.jsp.first_jsp._jspx_meth_f_view_0(org.apache.jsp.first_jsp:111)
    org.apache.jsp.first_jsp._jspService(org.apache.jsp.first_jsp:86)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

    I’m trying to run a .jsp extension. (http://localhost:8080/myApp/first.jsp).
    My first.jsp is very simple:

    <%@ page language=”java” pageEncoding=”UTF-8″%>
    <%@ taglib uri=”http://java.sun.com/jsf/html&#8221; prefix=”h” %>
    <%@ taglib uri=”http://java.sun.com/jsf/core&#8221; prefix=”f” %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
    %>

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <html>
    <head>
    <base href=”<%=basePath%>”>

    <title>My JSF ‘first.jsp’ starting page</title>

    <meta http-equiv=”pragma” content=”no-cache”>
    <meta http-equiv=”cache-control” content=”no-cache”>
    <meta http-equiv=”expires” content=”0″>
    <meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
    <meta http-equiv=”description” content=”This is my page”>
    <!–
    <link rel=”stylesheet” type=”text/css” href=”styles.css”>
    –>
    </head>

    <body>
    <f:view>
    <f:loadBundle basename=”BUNDLE_NAME_HERE” var=”bundle”/>
    This is my JSF JSP page. <br>
    </f:view>
    </body>
    </html>

    Thanks a lot,
    Efrat

    #243305 Reply

    Riyad Kalla
    Member

    You have to use .faces, look at your web.xml file, you mapped JSF to .faces, if you use. jsp you circumvent any JSF processing that *must* take place before the page is displayed.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: NullPointerException when trying to load JSF application

You must be logged in to post in the forum log in