Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

spring mvc with tiles hibernate validator @valid giving error

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to validate my form using JSR hibernate validator @valid annotation.
My application is configured with spring mvc 3 and tiles 2.
But when i submit the form to validate it given the following error

when submitting the form in createresource.jsp action=""
Ideally it should go to "jspCreateResource" tiles definition and show error messages on createresource.jsp (form page)

But it is giving the following error.

Please help me to validate this from properly.


javax.servlet.ServletException: Could not resolve view with name 'error' in servlet with name 'spring'
org.springframework.web.servlet.DispatcherServlet. render(
org.springframework.web.servlet.DispatcherServlet. doDispatch(
org.springframework.web.servlet.DispatcherServlet. doService(


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="";

<mvc:annotation-driven />
base-package="com.zoombra.controllers" />

<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBas edViewResolver">
<property name="viewClass">
org.springframework.web.servlet.view.tiles2.TilesV iew
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2 .TilesConfigurer">
<property name="definitions">

class="org.springframework.web.servlet.handler.Sim pleMappingExceptionResolver">
<property name="exceptionMappings">
<prop key="com.zoombra.exception.GenericRuntimeException ">
<prop key="java.lang.Exception">error</prop>

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="location">

<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSes sionFactoryBean">
<property name="dataSource" ref="hbmDataSource" />
<property name="hibernateProperties">
<prop key="hibernate.dialect">${jdbc.db.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.cache.use_second_level_cache">${hib ernate.cache.use_second_level_cache}</prop>
<prop key="hibernate.generate_statistics">${ nerate_statistics}</prop>
<prop key="hibernate.use_sql_comments">${hibernate.use_s ql_comments}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql} </prop>
<prop key="hibernate.use_sql_comments">${hibernate.use_s ql_comments}</prop>
<property name="annotatedClasses">

<bean id="hbmDataSource"
class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="${jdbc.db.driverClassName}" />
<property name="url" value="${jdbc.db.url}" />
<property name="username" value="${jdbc.db.username}" />
<property name="password" value="${jdbc.db.password}" />

<tx:annotation-driven />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.Hibernat eTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />



<definition name="base.definition"
<put-attribute name="title" value="" />
<put-attribute name="header1" value="/WEB-INF/jsp/header1.jsp" />
<put-attribute name="header2" value="/WEB-INF/jsp/header2.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 name="jspCreateResource" extends="base.definition">
<put-attribute name="title" value="Zoombra..." />
<put-attribute name="body" value="/WEB-INF/jsp/CreateResource.jsp" />

<definition name="welcome" extends="base.definition">
<put-attribute name="title" value="Zoombra..." />
<put-attribute name="body" value="/WEB-INF/jsp/welcome.jsp" />

<definition name="login.definition"
<put-attribute name="body" value="" />

<definition name="login" extends="login.definition">
<put-attribute name="body" value="/WEB-INF/jsp/login.jsp" />

<definition name="logout" extends="login.definition">
<put-attribute name="body" value="/WEB-INF/jsp/logout.jsp" />


Resource pojo
public class ResourcePojo {

@NotEmpty (message = "Employee Id can not be blank.")
private int empid;
@NotEmpty (message = "First Name can not be blank.")
@Size(max = 10 , message="First name should be between 1 to 50 Characters")
private String firstname;
@NotEmpty (message = "Last Name can not be blank.")


public class ResourceController {

@RequestMapping(value = "/createresource", method = RequestMethod.GET)
public ModelAndView createResource() {

Map model = new HashMap();
model.put("resource", new ResourcePojo());

return new ModelAndView("jspCreateResource", model);

@RequestMapping(value= "/submitCreateResource",method = RequestMethod.POST)
public String processForm(@ModelAttribute(value="resource") @Valid ResourcePojo resource
,BindingResult result,ModelMap model ,HttpSession session){

System.out.println("in processForm line 45");
return "jspCreateResource";
return null;


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@taglib uri=""; prefix="form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">;
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<form:form method="post" commandName="resource"

<form:errors path="empid" />
<form:errors path="firstname"/>
<form:errors path="lastname"/>

<table >
<td >
<h2>Create Resource</h2></td>
<table border="0" >
<td><form:label path="empid">Employee Id</form:label>
<td><form:input size="40" path="empid" />
<td><form:label path="firstname">First Name</form:label>
<td><form:input size="40" path="firstname" />
<td><form:label path="lastname">Last Name </form:label>
<td><form:input size="40" path="lastname" />
<td><form:label path="fullname">Full Name</form:label>
<td ><form:input size="40" path="fullname" />
<td><form:label path="dob">Date of Birth</form:label>
<td><form:input path="dob" />
<td><form:label path="companydoj">Company DOJ</form:label>
<td><form:input path="companydoj" />
<td><form:label path="projectdoj">Project DOJ</form:label>
<td><form:input path="projectdoj" />
<td><input type="submit" value="Submit" /></td>

You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic