Tiles 3 and Spring 3 integration throwing exception - spring

I am trying to integrate Spring 3 and Tiles 3, I am viewing the page fine and application is working fine but its giving me following error.
javax.servlet.ServletException: File "/WEB-INF/template/WEB-INF/template/layout.jsp" not found
Here are my configuration files.
<bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles3.TilesView"></property>
<property name="order" value="0"></property>
</bean>
<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
id="tilesConfigurer">
<property name="definitions" value="/WEB-INF/tiles.xml"></property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:I18N/messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/" />
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"></property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
this is my tiles.xml
<tiles-definitions>
<definition name="base.definition"
template='WEB-INF/template/layout.jsp'>
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/tile/header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/tile/footer.jsp" />
</definition>
<definition name="login" extends="base.definition">
<put-attribute name="title" value="login" />
<put-attribute name="body" value="/WEB-INF/tile/login.jsp" />
</definition>
here is my layout.jsp
<body bgcolor="">
<table border="1" cellpadding="2" cellspacing="2" align="center">
<tr>
<td height="20%" colspan="1"><tiles:insertAttribute
name="header" /></td>
</tr>
<tr>
<td width="350"><tiles:insertAttribute name="body" /></td>
</tr>
<tr>
<td height="10%" colspan="1"><tiles:insertAttribute
name="footer" /></td>
</tr>
</table>
What am I doing wrong here?
I spent hours on it, still cant figure it out.

Look at exception:
javax.servlet.ServletException: File "/WEB-INF/template/WEB-INF/template/layout.jsp" not found
Tiles tries to find "layout.js" at /WEB-INF/template/WEB-INF/template.
In
<definition name="base.definition"
template='WEB-INF/template/layout.jsp'>
Try to add "/" before template path:
<definition name="base.definition"
template='/WEB-INF/template/layout.jsp'>

Related

camel-sql consumer DB connection issue

I am using Apache Camel with Spring boot. I am using my spring boot app as jar without any server.
In app I am having a Camel-SQL consumer route with delay of 1000. This consumer then further calls other route which use splitter and parallel processing.
Through Jprofiler I have observed that my DB connection are not getting closed which are opened through consumer.
I also have dbcp2 settings in application.properties and using Oracle DB. I am observing this connection issue for the first time. Did anyone also faced the same issue at anytime? Or do I need to add any other configuration.
Any help will be appreciated.
Here is one of my Oracle configurations:
<cm:property-placeholder id="server.placeholder" persistent-id="name.of.company.datasource">
<cm:default-properties>
<cm:property name="db.host" value="host"/>
<cm:property name="db.port" value="1521"/>
<cm:property name="db.instance" value="dbname"/>
<cm:property name="db.user" value="user"/>
<cm:property name="db.password" value="password"/>
<cm:property name="driverClassName" value="oracle.jdbc.pool.OracleDataSource" />
<cm:property name="validationQuery" value="SELECT 1 FROM DUAL" />
<cm:property name="defaultReadOnly" value="false" />
<cm:property name="defaultAutoCommit" value="true" />
<cm:property name="maxActive" value="100" />
<cm:property name="whenExhaustedAction" value="2" />
<cm:property name="maxWait" value="-1" />
<cm:property name="maxIdle" value="8" />
<cm:property name="minIdle" value="1" />
<cm:property name="testOnBorrow" value="true" />
<cm:property name="testOnReturn" value="true" />
<cm:property name="timeBetweenEvictionRunsMillis" value="-1" />
<cm:property name="numTestsPerEvictionRun" value="3" />
<cm:property name="minEvictableIdleTimeMillis" value="1800000" />
<cm:property name="testWhileIdle" value="false" />
<cm:property name="softMinEvictableIdleTimeMillis" value="-1" />
<cm:property name="lifo" value="true" />
</cm:default-properties>
</cm:property-placeholder>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value= "${driverClassName}" />
<property name="url" value="jdbc:oracle:thin:#${db.host}:${db.port}:${db.instance}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.password}" />
<property name="maxIdle" value="1" />
</bean>
<bean id="connectionFactory" class="org.apache.commons.dbcp.DataSourceConnectionFactory">
<argument ref="dataSource" />
</bean>
<bean id="connectionPool" class="org.apache.commons.pool.impl.GenericObjectPool" >
<argument><null/></argument>
<argument value="${maxActive}" />
<argument value="${whenExhaustedAction}" />
<argument value="${maxWait}" />
<argument value="${maxIdle}" />
<argument value="${minIdle}" />
<argument value="${testOnBorrow}" />
<argument value="${testOnReturn}" />
<argument value="${timeBetweenEvictionRunsMillis}" />
<argument value="${numTestsPerEvictionRun}" />
<argument value="${minEvictableIdleTimeMillis}" />
<argument value="${testWhileIdle}" />
<argument value="${softMinEvictableIdleTimeMillis}" />
<argument value="${lifo}" />
</bean>
<bean id="pooledConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionFactory" >
<argument ref="connectionFactory" />
<argument ref="connectionPool" />
<argument><null/></argument>
<argument value="${validationQuery}" />
<argument value="${defaultReadOnly}" />
<argument value="${defaultAutoCommit}" />
</bean>
<bean id="poolingDataSource" class="org.apache.commons.dbcp.PoolingDataSource" depends-on="pooledConnectionFactory">
<argument ref="connectionPool" />
</bean>
<service interface="javax.sql.DataSource" ref="poolingDataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/oracle/db"/>
<entry key="datasource.name" value="jdbc/oracle/db" />
</service-properties>
</service>
Maybe it will help you.
I think DB connection just doesn't have time to go back to the pool between queries.
You need to configure the connection timeout and similar parameters (idle params, minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun).

Spring custom login form issue with Spring Security 4.0.2

I am using Spring MVC 4.2, Hibernate 4.2.20, Apache Tiles 3.0.5 & Spring Security 4.0.2.
Well, my project was running well until I tried to use CUSTOM login page and it fails.
Please look at below page when it works with in-built login.
Now when I tried to use CUSTOM login page I get below error and nothing specific error in the console.
I am NOT sure what could be wrong. Please look at further info below.
Project Structure
My Jars under /lib folder
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>SpringMVCHibernateProject</display-name>
<!-- global variables -->
<context-param>
<param-name>appRootPath</param-name>
<param-value>SpringMVCHibernateProject</param-value>
</context-param>
<!-- front controller -->
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<!-- default page to show when app starts -->
<!-- <mvc:view-controller path="/" view-name="Home"/> --> <!-- this is one way; another way defined in the HomeController.java (preferred) -->
<!-- essentially sets you your Spring context to allow for dispatching requests to Controllers -->
<mvc:annotation-driven />
<!-- used to load static resources like css, js etc... -->
<mvc:default-servlet-handler/>
<!-- automatically wire values into properties, methods, and constructors. -->
<context:annotation-config/>
<!-- scan for components like #Controller, #Repository, #Service, #Component etc...-->
<context:component-scan base-package="au.com.snh.*" />
<!-- spring view resolver bean....commented out in favour of Apache Tiles -->
<!--
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
-->
<!-- apache tiles...template framework -->
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
<property name="order" value="0" />
</bean>
<!-- load database properties file -->
<context:property-placeholder location="classpath:database.properties"/>
<!-- declare beans -->
<bean id="regionDao" class="au.com.snh.dao.RegionDaoImpl" />
<bean id="regionService" class="au.com.snh.service.RegionServiceImpl" />
<!-- declare datasource bean -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.pwd}" />
</bean>
<!-- hibernate -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="au.com.snh.model" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- resource bundles -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/propertybundle/common"/>
</bean>
<!-- spring secruity -->
<security:http auto-config="true" use-expressions="false">
<security:intercept-url pattern="/**" access="ROLE_USER" />
<security:form-login
login-page="/login"
login-processing-url="/j_spring_security_check"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password"
/>
<security:logout logout-success-url="/login?logout"/>
<security:csrf/>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="hitesh" password="hitesh123" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>
tiles.xml (Apache tiles)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="base" template="/WEB-INF/views/tiles/Template.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/views/tiles/Header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/views/tiles/Footer.jsp" />
</definition>
<definition name="login" extends="base">
<put-attribute name="title" value="Welcome to Spring MVC and Hibernate World!" />
<put-attribute name="body" value="/WEB-INF/views/login.jsp" />
</definition>
<definition name="Home" extends="base">
<put-attribute name="title" value="Welcome to Spring MVC and Hibernate World!" />
<put-attribute name="body" value="/WEB-INF/views/Home.jsp" />
</definition>
<!-- Location Views -->
<definition name="LocationList" extends="base">
<put-attribute name="title" value="Location List" />
<put-attribute name="body" value="/WEB-INF/views/LocationList.jsp" />
</definition>
<definition name="LocationAddEdit" extends="base">
<put-attribute name="title" value="Add/Edit Location" />
<put-attribute name="body" value="/WEB-INF/views/LocationAddEdit.jsp" />
</definition>
<!-- Region Views -->
<definition name="RegionList" extends="base">
<put-attribute name="title" value="Regions" />
<put-attribute name="body" value="/WEB-INF/views/RegionList.jsp" />
</definition>
<definition name="RegionAdd" extends="base">
<put-attribute name="title" value="Add Region" />
<put-attribute name="body" value="/WEB-INF/views/RegionAdd.jsp" />
</definition>
<definition name="RegionEdit" extends="base">
<put-attribute name="title" value="Edit Region" />
<put-attribute name="body" value="/WEB-INF/views/RegionEdit.jsp" />
</definition>
<!-- Student Admission Views -->
<definition name="AdmissionForm" extends="base">
<put-attribute name="title" value="Edit Region" />
<put-attribute name="body" value="/WEB-INF/views/AdmissionForm.jsp" />
</definition>
<definition name="AdmissionFormSuccess" extends="base">
<put-attribute name="title" value="Edit Region" />
<put-attribute name="body" value="/WEB-INF/views/AdmissionFormSuccess.jsp" />
</definition>
</tiles-definitions>
SecurityController.java
package au.com.snh.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class SecurityController {
#RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(#RequestParam(value = "error", required = false) String error, #RequestParam(value = "logout", required = false) String logout) {
System.out.println("login() start =>");
ModelAndView model = new ModelAndView();
if (error != null) {
model.addObject("error", "Invalid username and password!");
}
if (logout != null) {
model.addObject("msg", "You've been logged out successfully.");
}
model.setViewName("login");
System.out.println("login() start <=");
return model;
}
}
My Custom Login Form
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<div id="pageHeading">Login with Username and Password</div>
<div id="bodyContent">
<c:if test="${not empty error}">
<div class="error">${error}</div>
</c:if>
<c:if test="${not empty msg}">
<div class="msg">${msg}</div>
</c:if>
<form name='loginForm' action="<c:url value='j_spring_security_check' />" method='POST'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' id="username" name='username' value=''></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' id="password" name='password' /></td>
</tr>
<tr>
<td colspan='2'>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<input name="submit" type="submit" value="Login" />
</td>
</tr>
</table>
</form>
</div>
<script language="javascript">
document.getElementById("username").focus();
</script>
Can someone please tell me what could be wrong?
Looking forward to getting some help.
Thanks - Hitesh
Your login page is now a normal page displayed through DispatcherServlet instead of being generated by a Spring Security filter. So it must be accessible to non authenticated user. Currently, your security configuration requires a ROLE_USER for all pages... including /login. So here is what happens:
you make a request for any page before being authenticated
spring security detects that and redirect to /login page
browser sends a request for /login page without being authenticated
spring security detects that and redirect to /login page !
You must allow all accesses to /login page in dispatcher-servlet.xml:
<!-- spring secruity -->
<security:http auto-config="true" use-expressions="false">
<security:intercept-url pattern="/login"
access="IS_AUTHENTICATED_FULLY,IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
...
alternatively, you can create a dedicated security zone for /login fully by-passing security:
<!-- spring secruity -->
<security:http pattern = "/login*" security="none">
<security:http auto-config="true" use-expressions="false">
<security:intercept-url pattern="/**" access="ROLE_USER" />
...
It is not redirecting properly
Try to add the default-target-url
<security:form-login login-page="/login" default-target-url="/" authentication-failure-url="/login?error=true" />

EF 5 with oracle edmx StoreGeneratedPattern="Identity" issue

We are using EF5 with Oracle[Oracle.manageddataaccess.client].Whenever I create/refresh edmx.I loose the property StoreGeneratedPattern="Identity". I had to set this manually for each and every Entity.
Is there any way to automate it or any other work around ? am I missing something here ?
We use VS2013,Below is the sample entity in the edmx after create.
<EntityType Name="ADDRESS">
<Key>
<PropertyRef Name="ADDRESS_ID" />
</Key>
<Property Name="ADDRESS_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="CLIENT_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="USER_ID" Type="number" Precision="38" Scale="0" />
<Property Name="ADDRESS_ACT_FLG" Type="number" Precision="38" Scale="0" />
<Property Name="ADDRESS_1" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_2" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_3" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_4" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_SUFFIX" Type="char" MaxLength="2" />
<Property Name="COUNTY" Type="varchar2" MaxLength="50" />
<Property Name="CITY" Type="varchar2" MaxLength="50" />
<Property Name="STATE_PROVINCE" Type="varchar2" MaxLength="75" />
<Property Name="COUNTRY" Type="varchar2" MaxLength="50" />
<Property Name="POSTAL_CODE" Type="varchar2" MaxLength="10" />
<Property Name="ADDRESS_TYPE" Type="varchar2" MaxLength="2" />
<Property Name="PRIMARY_ADDRESS_IND" Type="number" Precision="38" Scale="0" />
<Property Name="CREATED_USER_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="CREATED_DATE" Type="timestamp" Precision="6" Nullable="false" />
<Property Name="MODIFIED_USER_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="MODIFIED_DATE" Type="timestamp" Precision="6" Nullable="false" />
</EntityType>
I have written a short blog post about it: http://blog.aitgmbh.de/2014/06/02/patch-for-entity-framework-models-based-on-oracle-databases/
There I also refer to a NuGet package that I have created: http://bit.ly/1hbxIsO
This adds MSBuild scripts that manipulate the edmx file automatically.
It basically lets you define which columns should be identity columns and ensures at every build that the StoreGeneratedPattern property of these identity columns is set to "Identity".
Update: The patch is now also available on GitHub.

Can a Tiles definition extend a definition defined in an external jar using Spring TilesConfigurer?

Library Versions: Spring 3.1.2, Tiles 2.2.2
Given the following setup, is it possible to extend and use a tile definition (i.e. "BaseTile" below) from an external (common) .jar?
common.jar
/WEB-INF/common-tiles-defs.xml
<tiles-definitions>
<definition name="BaseTile" template="/WEB-INF/tiles/BaseTile.jsp">
<put-attribute name="content" value="" />
</definition>
</tiles-definitions>
someproject.war
/WEB-INF/tiles-defs.xml
<tiles-definitions>
<definition name="ProjectTile" extends="BaseTile">
<put-attribute name="content" expression="${someData}" />
</definition>
</tiles-definitions>
servlet-context.xml
<beans:beans>
<!-- Tiles Configuration: View Resolver -->
<beans:bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass">
<beans:value>org.springframework.web.servlet.view.tiles2.TilesView</beans:value>
</beans:property>
<beans:property name="order" value="1" />
</beans:bean>
<!-- Tiles Configuration: Definitions -->
<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>classpath:/WEB-INF/common-tiles-defs.xml</beans:value> <!-- from common.jar -->
<beans:value>/WEB-INF/tiles-defs.xml</beans:value> <!-- from someproject.war -->
</beans:list>
</beans:property>
</beans:bean>
</beans:beans>
When I deploy the webapp (someproject.war), it appears to find the common-tiles-defs.xml inside common.jar, but when I try to render "ProjectTile", Tiles' DEBUG log outputs the following:
||20130716||15:20:36,074||||org.apache.tiles.access.TilesAccess||INFO ||Publishing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
||20130716||15:20:37,589||||org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO||DEBUG||Resolve definition for child name='ProjectTile' extends='BaseTile'.
||20130716||15:20:37,590||||org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO||DEBUG||File null not found, continue
||20130716||15:20:37,591||||org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO||DEBUG||File null not found, continue
Any help would be greatly appreciated.
Thank you.

Tiles 2 + Spring: Attribute not found

I'm working on integrating Tiles 2 with Spring, but have a problem. I have a simple tiles.jsp page. Rendering tiles view produce error: org.apache.tiles.template.NoSuchAttributeException: Attribute 'title' not found.My configuration and files below.
Tiles config:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="1">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="0">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/defs/templates.xml</value>
</list>
</property>
</bean>
Definitions in /WEB-INF/defs/templates.xml:
<tiles-definitions>
<!-- Default Main Template -->
<definition name="base" template="/WEB-INF/pages/tiles.jsp">
<put-attribute name="title" value="Empty" type="string" />
<put-attribute name="header" value="/WEB-INF/tiles-templates/header.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles-templates/footer.jsp" />
<put-attribute name="body" value="/WEB-INF/tiles-templates/blank.jsp" />
</definition>
<definition name="tiles" extends="base">
<put-attribute name="title" value="Simple Tiles 2 Example"/>
</definition>
</tiles-definitions>
Controller:
#Controller
public class MainController {
#RequestMapping("/tiles")
public String tiles() {
return "tiles";
}
}
/WEB-INF/pages/tiles.jsp:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
<title><tiles:getAsString name="title" /></title>
<link rel="stylesheet" type="text/css" href="<c:url value="/css/main.css"/>" />
</head>
<body>
<div id="header">
<div id="headerTitle"><tiles:insertAttribute name="header" /></div>
</div>
<div id="content">
<tiles:insertAttribute name="body" />
</div>
<div id="footer">
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
Resolved! I've removed suffix and prefix properties from tilesViewResolver and everything began work.
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="0">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>

Resources