You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Abhishek Vishwakarma <ab...@gmail.com> on 2012/12/23 13:40:32 UTC
Issue with Nested Tiles while integrating with Spring 3.0
Hi,
I am trying to create one sample applicaiton on nested tiles with spring
3.0. (Attached source code of sample application at the end)
When I am running the application below is the error [12/22/12 18:02:20:968
IST] 00000057 ServletWrappe E SRVE0068E: Uncaught exception thrown in one
of the service methods of the servlet: /WEB-INF/jsp/layout.jsp. Exception
thrown : java.lang.ClassCastException: java.lang.String incompatible with
org.apache.tiles.Attribute
at
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
at
com.ibm._jsp._layout._jspx_meth_tiles_insertAttribute_3(_layout.java:168)
at com.ibm._jsp._layout._jspx_meth_c_forEach_0(_layout.java:188)
at com.ibm._jsp._layout._jspService(_layout.java:101)
at
com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1102)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at
com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:226)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
at
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
at
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
at
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
at
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
at
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1157)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1102)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:518)
at com.ibm._jsp._index._jspService(_index.java:64)
at
com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1102)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at
com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:226)
at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
[12/22/12 18:02:20:968 IST] 00000057 LocalTranCoor E WLTC0017E: Resources
rolled back due to setRollbackOnly() being called.
[12/22/12 18:02:20:968 IST] 00000057 ServletWrappe E SRVE0068E: Uncaught
exception thrown in one of the service methods of the servlet: spring.
Exception thrown : org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is
java.lang.ClassCastException: java.lang.String incompatible with
org.apache.tiles.Attribute
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1102)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:518)
at com.ibm._jsp._index._jspService(_index.java:64)
at
com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1102)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at
com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at
com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:226)
at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: java.lang.ClassCastException: java.lang.String incompatible with
org.apache.tiles.Attribute
at
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
at
com.ibm._jsp._layout._jspx_meth_tiles_insertAttribute_3(_layout.java:168)
at com.ibm._jsp._layout._jspx_meth_c_forEach_0(_layout.java:188)
*Source code goes as below*
spring xml file
--------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan
base-package="net.viralpatel.spring3.controller"
/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles2.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
</beans>
tiles.xml
----------
<?xml version=*"1.0"* encoding=*"UTF-8"* ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name=*"base.definition"* template=*
"/WEB-INF/jsp/layout.jsp"*>
<put-attribute name=*"title"* value=*""* />
<put-attribute name=*"header"* value=*"/WEB-INF/jsp/header.jsp"*
/>
<put-attribute name=*"menu"* value=*"/WEB-INF/jsp/menu.jsp"* />
<put-attribute name=*"body"* value=*""* />
<put-attribute name=*"footer"* value=*"/WEB-INF/jsp/footer.jsp"*
/>
</definition>
<definition name=*"contact"* extends=*"base.definition"*>
<put-attribute name=*"title"* value=*"Contact Manager"* />
<put-list-attribute name=*"body"*>
<add-attribute value=*"/WEB-INF/jsp/contact.jsp"*></
add-attribute>
</put-list-attribute>
</definition>
</tiles-definitions>
layout.jsp
----------
<%@ taglib uri=*"http://tiles.apache.org/tags-tiles"* prefix=*"tiles"*%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri=*"http://java.sun.com/jstl/core_rt"* prefix=*"c"* %>
<%@page import=*"java.util.ArrayList"*%><html>
<head>
<meta http-equiv=*"Content-Type"* content=*"text/html; charset=UTF-8"*>
<title><tiles:insertAttribute name=*"title"* ignore=*"true"* /></title>
</head>
<body>
<tiles:useAttribute classname=*"java.util.List"* id=*"bodyList"* name=*
"body"*/>
<table border=*"1"* cellpadding=*"2"* cellspacing=*"2"* align=*"center"*>
<tr>
<td height=*"30"* colspan=*"2"*><tiles:insertAttribute name=*
"header"* />
</td>
</tr>
<tr>
<td height=*"250"*><tiles:insertAttribute name=*"menu"* /></td>
<c:forEach var=*"bodyItems"* items="${bodyList}" >
<td width=*"350"*><tiles:insertAttribute value="
${bodyItems}"></tiles:insertAttribute> </td>
</c:forEach>
</tr>
<tr>
<td height=*"30"* colspan=*"2"*><tiles:insertAttribute name=*
"footer"* />
</td>
</tr>
</table>
</body>
</html>
When I say *"*><tiles:insertAttribute value="${bodyItems}"></
tiles:insertAttribute> </td> here it is throwing exception and I am using
below jars
tiles-api-2.2.2.jar
tiles-core-2.2.2.jar
tiles-jsp-2.2.2.jar
tiles-servlet-2.2.2.jar
tiles-template-2.2.2.jar
standard-1.0.6.jar along with spring 3.0 version jars
Please advise on above.
Thanks
Re: Issue with Nested Tiles while integrating with Spring 3.0
Posted by Abhishek Vishwakarma <ab...@gmail.com>.
Hi Nick,
Thanks a lot for your suggestion.
As suggested by you I have tried to change the <tiles:insetAttribute> to
<tiles:insertTemplate> and run the application in my sample application
where all the tiles are defined in single tiles file which works fine. When
I am applying the same in my internationalization application then I am
getting below error in Internet explorer.
Please can you advise on same. For reference attached (code snippet and
tiles configurations).
*Error 403: SRVE0190E: File not found:
/WEB-INF/MyApp/common/tiles/layouts/${bodyItem} ** *
Here I have my tiles-defs.xml as well as tiles-ukd-defs.xml.
The extend layout (parent) is configured in *tiles-defs.xml* like below
<definition name="ActionEnroll"
template="/WEB-INF/MyApp/common/tiles/layouts/main.jsp">
<put-attribute name="Header1"
value="/WEB-INF/MyApp/common/common/topnav.jsp" />
<put-list-attribute name="body">
</put-list-attribute>
Below is my* tiles-UKD-defs.xml* where I am extending parent definition
<definition name="enroll.UKD" extends="ActionEnroll">
<put-list-attribute name="body">
<add-attribute
value="/WEB-INF/MyApp/common/tiles/enroll/a.jsp" />
</put-list-attribute>
</definition>
In main.jsp I have written as you suggest like this
<tiles:useAttribute id="bodyList" name="body" classname="java.util.List" />
<c:forEach var="bodyItem" items="${bodyList}" >
<tr>
<td valign="top" align='left'>
<tiles:insertTemplate template="${bodyItem}"
flush="false" />
</td>
</tr>
</c:forEach>
But this is giving error in the explorer as
*Error 403: SRVE0190E: File not found:
/WEB-INF/MyApp/common/tiles/layouts/${bodyItem} ** *
But when I iterate the bodyItem in scriptlet like below
Iterator it=bodyList.iterator();
System.out.println(“jspà”+it.next())
then it is properly giving the file path of a.jsp like
WEB-INF/MyApp/common/tiles/enroll/a.jsp
Regards,
Abhishek
On Sun, Dec 23, 2012 at 11:58 PM, Nicolas LE BAS <ma...@nlebas.net> wrote:
> Hi,
>
> Keeping things short: the problem happens because you shouldn't be using
> tiles:insertAttribute for this purpose. Use tiles:insertTemplate instead.
>
> The difference is simple: tiles:insertAttribute is in charge of
> retrieving the value of an attribute (given its name or the Attribute
> object). Once that value is known, tiles:insertAttribute internally
> calls insertTemplate for rendering.
>
> In your situation, tiles:useAttribute is retrieving the value of the
> attribute and assigning it to a JSP "variable". What's left is only
> rendering it, with insertTemplate.
>
> Hope this helps,
> Nick.
>
> PS: for further details about insertTemplate syntax, please see
> http://tiles.apache.org/2.2/framework/tiles-jsp/tlddoc/index.html
>
> On 12-12-23 07:40 AM, Abhishek Vishwakarma wrote:
> [...]
> > <definition name=*"contact"* extends=*"base.definition"*>
> >
> > <put-attribute name=*"title"* value=*"Contact Manager"* />
> >
> > <put-list-attribute name=*"body"*>
> >
> > <add-attribute value=*"/WEB-INF/jsp/contact.jsp"*></
> > add-attribute>
> >
> > </put-list-attribute>
> >
> > </definition>
> [...]
> > <tiles:useAttribute classname=*"java.util.List"* id=*"bodyList"* name=*
> > "body"*/>
> [...]
> > <c:forEach var=*"bodyItems"* items="${bodyList}" >
> >
> >
> >
> > <td width=*"350"*><tiles:insertAttribute value="
> > ${bodyItems}"></tiles:insertAttribute> </td>
> >
> > </c:forEach>
> [...]
> > When I say *"*><tiles:insertAttribute value="${bodyItems}"></
> > tiles:insertAttribute> </td> here it is throwing exception and I am
> using
> > below jars
>
>
>
Re: Issue with Nested Tiles while integrating with Spring 3.0
Posted by Nicolas LE BAS <ma...@nlebas.net>.
Hi,
Keeping things short: the problem happens because you shouldn't be using
tiles:insertAttribute for this purpose. Use tiles:insertTemplate instead.
The difference is simple: tiles:insertAttribute is in charge of
retrieving the value of an attribute (given its name or the Attribute
object). Once that value is known, tiles:insertAttribute internally
calls insertTemplate for rendering.
In your situation, tiles:useAttribute is retrieving the value of the
attribute and assigning it to a JSP "variable". What's left is only
rendering it, with insertTemplate.
Hope this helps,
Nick.
PS: for further details about insertTemplate syntax, please see
http://tiles.apache.org/2.2/framework/tiles-jsp/tlddoc/index.html
On 12-12-23 07:40 AM, Abhishek Vishwakarma wrote:
[...]
> <definition name=*"contact"* extends=*"base.definition"*>
>
> <put-attribute name=*"title"* value=*"Contact Manager"* />
>
> <put-list-attribute name=*"body"*>
>
> <add-attribute value=*"/WEB-INF/jsp/contact.jsp"*></
> add-attribute>
>
> </put-list-attribute>
>
> </definition>
[...]
> <tiles:useAttribute classname=*"java.util.List"* id=*"bodyList"* name=*
> "body"*/>
[...]
> <c:forEach var=*"bodyItems"* items="${bodyList}" >
>
>
>
> <td width=*"350"*><tiles:insertAttribute value="
> ${bodyItems}"></tiles:insertAttribute> </td>
>
> </c:forEach>
[...]
> When I say *"*><tiles:insertAttribute value="${bodyItems}"></
> tiles:insertAttribute> </td> here it is throwing exception and I am using
> below jars