Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in Tiles2 intrigation with jsf when we keep jsp in folder location

 
H saxena
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.getServletMapping




I have download “myfaces-example-tiles-1.1.10” from official apache web site. As it is code and I hvae create new one application it is working fine with java 1.5 and tomcat 6 in my eclipse.
This example keep jsp file page1.jsp in root folder when we move this file in any other folder it geives error.
When I put the home.jsp file in any folder it is given the error below are details what I have done and what I want and wht is the error.

Error message which I got:

An Error Occurred:
javax.faces.FacesException

Caused by:
java.io.IOException - Error including path '/template/template.jsp'. java.lang.NullPointerException: context
+- Stack Trace
javax.faces.FacesException
at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.renderTilesView(JspTilesTwoViewHandlerImpl.java:126)
at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.renderView(JspTilesTwoViewHandlerImpl.java:110)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:146)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:147)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:426)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:255)
at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.renderView(JspTilesTwoViewHandlerImpl.java:92)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:146)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:147)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.tiles.TilesException: Error including path '/template/template.jsp'. java.lang.NullPointerException: context
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:427)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:370)
at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.renderTilesView(JspTilesTwoViewHandlerImpl.java:124)
... 31 more
Caused by: java.io.IOException: Error including path '/template/template.jsp'. java.lang.NullPointerException: context
at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:201)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:185)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:419)
... 33 more



This is the project struture:::----






This is the jar file which I am using in my proect:



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>MCMS</display-name>

<!-- Tiles ViewHandler config file -->
<context-param>
<description>Tiles configuration
definition files and a listener need to be defined.
the listener will initialize JspTilesViewHandlerImpl with tiles definitions.
</description>
<param-name>tiles-definitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.

Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SourceCodeServlet</servlet-name>
<servlet-class>org.apache.myfaces.shared_tomahawk.util.servlet.SourceCodeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/jsp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
</web-app>


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">
<faces-config>
<application>
<view-handler>org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl</view-handler>
</application>

<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>nav_page1</from-outcome>
<to-view-id>/jsp/home.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

tiles.xml:---
<!DOCTYPE tiles-definitions
[
<!ENTITY % Boolean "(true|false)">
<!ENTITY % ContentType "(string|template|definition|object)">
<!ENTITY % ClassName "CDATA">
<!ENTITY % RequestPath "CDATA">
<!ENTITY % DefinitionName "CDATA">
<!ENTITY % BeanName "CDATA">
<!ENTITY % PropName "CDATA">
<!ENTITY % Location "#PCDATA">
<!ELEMENT tiles-definitions (definition+)>
<!ELEMENT definition (icon?, display-name?, description?, put-attribute*, put-list-attribute*)>
<!ATTLIST definition id ID #IMPLIED>
<!ATTLIST definition preparer CDATA #IMPLIED>
<!ATTLIST definition extends CDATA #IMPLIED>
<!ATTLIST definition name CDATA #REQUIRED>
<!ATTLIST definition role CDATA #IMPLIED>
<!ATTLIST definition template CDATA #IMPLIED>
<!ELEMENT put-attribute (#PCDATA)>
<!ATTLIST put-attribute id ID #IMPLIED>
<!ATTLIST put-attribute name CDATA #REQUIRED>
<!ATTLIST put-attribute type (string|template|definition|object) #IMPLIED>
<!ATTLIST put-attribute value CDATA #IMPLIED>
<!ATTLIST put-attribute role CDATA #IMPLIED>
<!ELEMENT put-list-attribute ( (add-attribute* | item* | bean* | add-list-attribute*)+) >
<!ATTLIST put-list-attribute id ID #IMPLIED>
<!ATTLIST put-list-attribute name CDATA #REQUIRED>
<!ATTLIST put-list-attribute role CDATA #IMPLIED>
<!ELEMENT add-attribute (#PCDATA)>
<!ATTLIST add-attribute id ID #IMPLIED>
<!ATTLIST add-attribute type (string|template|definition|object) #IMPLIED>
<!ATTLIST add-attribute value CDATA #IMPLIED>
<!ATTLIST add-attribute role CDATA #IMPLIED>
<!ELEMENT add-list-attribute ( (add-attribute* | item* | bean* | add-list-attribute*)+) >
<!ATTLIST add-list-attribute id ID #IMPLIED>
<!ATTLIST add-list-attribute role CDATA #IMPLIED>
<!ELEMENT bean (set-property*)>
<!ATTLIST bean id ID #IMPLIED>
<!ATTLIST bean classtype CDATA #REQUIRED>
<!ELEMENT set-property EMPTY>
<!ATTLIST set-property id ID #IMPLIED>
<!ATTLIST set-property property CDATA #REQUIRED>
<!ATTLIST set-property value CDATA #REQUIRED>
<!ELEMENT item (#PCDATA)>
<!ATTLIST item id ID #IMPLIED>
<!ATTLIST item classtype CDATA #IMPLIED>
<!ATTLIST item icon CDATA #IMPLIED>
<!ATTLIST item link CDATA #REQUIRED>
<!ATTLIST item tooltip CDATA #IMPLIED>
<!ATTLIST item value CDATA #REQUIRED>
<!ELEMENT description (#PCDATA)>
<!ATTLIST description id ID #IMPLIED>
<!ELEMENT display-name (#PCDATA)>
<!ATTLIST display-name id ID #IMPLIED>
<!ELEMENT icon (small-icon?, large-icon?)>
<!ATTLIST icon id ID #IMPLIED>
<!ELEMENT large-icon (#PCDATA)>
<!ATTLIST large-icon id ID #IMPLIED>
<!ELEMENT small-icon (#PCDATA)>
<!ATTLIST small-icon id ID #IMPLIED>

]>

<tiles-definitions>
<definition name="layout.example" template="/template/template.jsp" >
<put-attribute name="header" value="/common/header.jsp" />
<put-attribute name="menu" value="/common/menu.jsp" />
</definition>

<definition name="/home.tiles" extends="layout.example" >
<put-attribute name="body" value="/jsp/home.jsp" />
</definition>

</tiles-definitions>
template.jsp:--
------
<%@ 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 uri="http://tiles.apache.org/tags-tiles" prefix="tiles"
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1" />
<title>Myfaces - Tiles</title>
<link rel="stylesheet" type="text/css" href="css/tiles.css" />
</head>
<f:view>
<body>
<div id="lftBar">
<f:subview id="menu">
<tiles:insertAttribute name="menu" flush="false" />
</f:subview>
</div>
<div id="level0">
<div id="level1">
<div id="topBar">
<f:subview id="header">
<tiles:insertAttribute name="header" flush="false"/>
</f:subview>
</div>
<div id="level2">
<f:subview id="content">
<tiles:insertAttribute name="body" flush="false"/>
</f:subview>
</div>
</div>
</div>
</body>
</f:view>
header.jsp:---
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"
%><h:graphicImage id="logo" url="/images/logo.jpg" />
menu.jsp:--
------
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<h:form>
<h:panelGrid columns="1" >
<h:commandLink action="nav_page1">
<hutputText value="Page1" />
</h:commandLink>
</h:panelGrid>
</h:form>
----------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic