You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by logancillo <al...@gmail.com> on 2007/10/10 13:40:30 UTC

myfaces, tiles NullPointerException

I am doing a demo that it uses myfaces, spring and i wanted to construct the
user's interfaz with tiles or with something similar.

I use the netbeans 5.5 with myfaces-api and myfaces-impl 1.1.4, tomahawk and
tomahawk-sandbox 1.1.6 and struts 1.1.
I have followed(continued) the instructions of http: //
wiki.apache.org/myfaces/Tiles_and_JSF to the letter and on having
opened(deploied), it(he,she) gives me the following exception:

javax.faces.FacesException
	at
de.mindmatters.faces.lifecycle.RenderResponsePhase.executePhase(RenderResponsePhase.java:53)
	at
de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37)
	at
de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:166)
	at
de.mindmatters.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:226)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
	at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:406)
	at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
	at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:313)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
	at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
	at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
	at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
Caused by: java.lang.NullPointerException
	at
org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:168)
	at
org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
	at
org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:221)
	at
de.mindmatters.faces.lifecycle.RenderResponsePhase.executePhase(RenderResponsePhase.java:45)
	... 21 more

my web.xml is 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
    <context-param>
        <param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>true</param-value>
        <description>
            Set this flag to true if you want the JSF
            Reference Implementation to verify that all of the application
            objects you have configured (components, converters,
            renderers, and validators) can be successfully created.
            Default value is false.
            Poner a false cuando se ponga en produccion.
        </description>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
        <description>
            Set this flag to true if you want the JSF
            Reference Implementation to validate the XML in your
            faces-config.xml resources against the DTD.  Default
            value is false.
            Poner a false cuando se ponga en produccion.
        </description>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
        <description>
            Indica donde queremos guardar el estado de la aplicacion.
            Poner a server cuando se ponga en produccion. antes probarlo!
        </description>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
        <description>
            Este parametro le dice a MyFaces si se va a permitir renderizar
javascript.
            Default: "true"
        </description>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
        <description>
            si es verdadero, el renderizado html estara formateado,
permitiendo que se pueda leer 
            bien. En la fase de desarrollo, estara a true, cuando este en
produccion, estara a false.
        </description>
    </context-param>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
	<welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>
    
    <!-- Listener, that does all the startup work (configuration, init). -->
    <listener>
       
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
    <!-- listener de spring-->
    <listener>  
       
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>  
    </listener>
    <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Tiles configuration
         definition files and a listener need to be defined.
         the listener will initialize JspTilesViewHandlerImpl with tiles
definitions.
    -->
    <servlet> 
        <servlet-name>TilesServet</servlet-name> 
           
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class> 
            <init-param> 
                <param-name>definitions-config</param-name> 
                <param-value>/WEB-INF/tiles-defs.xml</param-value> 
            </init-param> 
            <load-on-startup>2</load-on-startup> 
    </servlet> 
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
       
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    </filter>
</web-app>

tiles-defs.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">

<tiles-definitions>
    
    <definition name="Base" path="/paginas/plantillaBasica.jsp">		
		<put name="titulo" value="Base" type="string"/>
                <put name="cabecera" value="/cabecera.jsp" type="page"/>  
		<put name="cuerpo" value="base" type="page"/> 
                <put name="seo" value="seo" type="page"/>
		<put name="pie" value="base" type="page"/> 
    </definition>

    <definition name="/faces/busquedaDosCajas.tiles" extends="Base">		
		<put name="titulo" value="Busqueda con dos cajas" type="string"/>
		<put name="cuerpo" value="/paginas/cuerpoDosCajas.jsp" type="page"/>  
    </definition>
    
</tiles-definitions>

index.jsp

<%response.sendRedirect("/faces/busquedaDosCajas.jsp");%>

plantillaBasica.jsp

<!-- aqui vendrian la definicion de los taglib -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>
            <tiles:getAsString name="titulo"/>
        </title>
        <!-- Aqui vendrian las css-->
    </head>
    <f:view>
        <f:loadBundle basename="MessageResources" var="msg"/>
        <body>
            <f:subview id="cabecera">
                <tiles:insert attribute="cabecera" flush="false"/>
            </f:subview>
            <f:subview id="cuerpo">
                <tiles:insert attribute="cuerpo" flush="false"/>
            </f:subview>
            <f:subview id="seo">
                <tiles:insert attribute="seo" flush="false"/>
            </f:subview>
            <f:subview id="pie">
                <tiles:insert attribute="pie" flush="false"/>
            </f:subview>
        </body>
    </f:view>
</html>

The directory /paginas is on level of the webapp.

It seems as if JspTilesViewHandlerImpl was not initialized correctly,

snippet from renderView at JspTilesViewHandlerImpl
/* 168*/        try {
/* 168*/            definition =
getDefinitionsFactory().getDefinition(tilesId, request, servletContext);  

pls help!
-- 
View this message in context: http://www.nabble.com/myfaces%2C-tiles-NullPointerException-tf4600255.html#a13134071
Sent from the MyFaces - Users mailing list archive at Nabble.com.