Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:17:40+00:00 2026-05-27T01:17:40+00:00

My entity has bean validation annotations @NotBlank and @Size on the name field. However,

  • 0

My entity has bean validation annotations @NotBlank and @Size on the name field. However, when I submit the JSF form with the name field left blank, it doesn’t validate the field.

Here’s the field in question:

@NotBlank(message = "{name.required}")
@Size(max = 25, message = "{long.value}")
@Column(name = "name", length = 25, nullable = false)
private String name;

When submitting the form without entering any data, I am getting the following exception:

Caused by: javax.faces.el.EvaluationException: javax.validation.ConstraintViolationException: validation failed for classes [com.myapp.domain.Department] during persist time for groups [javax.validation.groups.Default, ]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 89 more
Caused by: javax.validation.ConstraintViolationException: validation failed for classes [com.myapp.domain.Department] during persist time for groups [javax.validation.groups.Default, ]
    at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:132)
    at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:71)
    at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:177)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:72)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy212.addDepartment(Unknown Source)
    at com.myapp.beans.DepartmentBean.addOrUpdateDepartment(DepartmentBean.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

How is this caused and now can I solve it?


Update: here’s the relevant part of the view:

<h:form>         
    <ice:panelGrid columns="3">
        <h:outputLabel>Department Name:</h:outputLabel>
        <h:inputText id="name" value="#{departmentBean.departmentObj.name}" />
        <h:message for="name" />
    </ice:panelGrid>        
</h:form>
<h:form>
    <ice:panelGroup>
        <h:commandLink value="Add New" action="#{departmentBean.addOrUpdateDepartment}" />
    </ice:panelGroup>
</h:form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:17:40+00:00Added an answer on May 27, 2026 at 1:17 am

    From the stacktrace:

    at com.myapp.beans.DepartmentBean.addOrUpdateDepartment(DepartmentBean.java:105)
    ...
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    

    This means that your JSF bean action method is invoked anyway while this should have been blocked by the validation constraints on the empty name field and you should have seen a validation error in a <h:message> or <h:messages> of the form.

    That can only mean that you’ve put immeditate="true" on the command button/link which would cause all input components which don’t have this attribute will be skipped in form processing:

    <h:commandButton ... immediate="true" />
    

    or that you’ve this context parameter in your web.xml which would skip validation of empty fields:

    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>false</param-value>
    </context-param>
    

    or that you have disabled the bean validation in your view by the following tag:

    <f:validateBean disabled="true" />
    

    Make sure that you have none of them.


    Update: as per your update, you’ve made a classic mistake: you’ve put the submit button in a different form than the input fields. The submit button needs to go in the same form as the input fields which you would like to send along with the submit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A have a JPA entity that has timestamp field and is distinguished by a
I have a JPA entity Person which has a @Version long version field. I
I am writing a JSF 2.0 form to edit a JPA @Entity object. I
I have a simple bean @Entity Message.java that has some normal properties. The life-cycle
I have a data structure where an entity has times stored as an int
i have a table where a Collection has many Entities and an Entity has
I have a document-based Core Data app. My main Core Data entity has several
Entity Framework has created the required partial classes. I can add these partial classes
I have an entity that has a state table associated with it. The state
I have Person entity which has composition with Location Entity @ManyToOne(fetch = FetchType.EAGER, cascade

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.