ninada / full-hibernate-plugin-for-struts2

Automatically exported from code.google.com/p/full-hibernate-plugin-for-struts2
1 stars 0 forks source link

org.hibernate.validator.InvalidStateException: validation failed for: com.vaannila.domain.User #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Validation errors are not displayed on the screen
2. Tried both properties file message values and annotation based message
values both not getting displayed.
3. I followed all the steps as stated.

What is the expected output? What do you see instead?
Validation Error messages should appear on the jsp page.

What version of the product are you using? On what operating system?
Windows operating system, eclipse ide all versions of the jar file as stated.

Please provide any additional information below.

Domain object 
-------------

package com.vaannila.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.NotEmpty;

@Entity
@Table(name = "USER")
public class User implements Serializable {

    private static final long serialVersionUID = 6295524232169619097L;

    private Long id;

    @NotEmpty(message = "Name Required")
    private String name;

    private String password;

    private String gender;

    private String country;

    private String aboutYou;

    private Boolean mailingList;

    @Id
    @GeneratedValue
    @Column(name = "USER_ID")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "USER_NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "USER_PASSWORD")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "USER_GENDER")
    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Column(name = "USER_COUNTRY")
    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    @Column(name = "USER_ABOUT_YOU")
    public String getAboutYou() {
        return aboutYou;
    }

    public void setAboutYou(String aboutYou) {
        this.aboutYou = aboutYou;
    }

    @Column(name = "USER_MAILING_LIST")
    public Boolean getMailingList() {
        return mailingList;
    }

    public void setMailingList(Boolean mailingList) {
        this.mailingList = mailingList;
    }

}

----------------------------------------------------

Action class
------------

package com.vaannila.web;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.validator.Valid;

import com.opensymphony.xwork2.ActionSupport;
import com.vaannila.dao.UserDAO;
import com.vaannila.dao.UserDAOImpl;
import com.vaannila.domain.User;

public class UserAction extends ActionSupport {

    private static final long serialVersionUID = -6659925652584240539L;

    @Valid
    private User user;
    private List<User> userList = new ArrayList<User>();

    public String add()
    {
        UserDAO userDAO = new UserDAOImpl();
        userDAO.saveUser(user);
        return SUCCESS;
    }

    public String list()
    {
        UserDAO userDAO = new UserDAOImpl();
        userList = userDAO.listUser();
        return SUCCESS;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

}

---------------------------------------------

UserAction.properties
---------------------

user.name=User Name
user.password=Password
user.gender=Gender
user.country=Country
user.aboutYou=About You
user.mailingList=Mailing List

-------------------------------------------

org.hibernate.validator.InvalidStateException: validation failed for:
com.vaannila.domain.User
    at
org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListen
er.java:148)
    at
org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventLis
tener.java:172)
    at
org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAc
tion.java:142)
    at
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertActi
on.java:65)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    at
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(Abstrac
tSaveEventListener.java:321)
    at
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventL
istener.java:204)
    at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSa
veEventListener.java:130)
    at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequ
estedId(DefaultSaveOrUpdateEventListener.java:210)
    at
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(
DefaultSaveEventListener.java:56)
    at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(Defau
ltSaveOrUpdateEventListener.java:195)
    at
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSave
EventListener.java:50)
    at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultS
aveOrUpdateEventListener.java:93)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
    at com.vaannila.dao.UserDAOImpl.saveUser(UserDAOImpl.java:40)
    at com.vaannila.web.UserAction.add(UserAction.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvoca
tion.java:440)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionIn
vocation.java:279)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:242)
    at
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(Defau
ltWorkflowInterceptor.java:163)
    at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilt
erInterceptor.java:87)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(Convers
ionErrorInterceptor.java:122)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(Parameters
Interceptor.java:195)
    at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilt
erInterceptor.java:87)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(Static
ParametersInterceptor.java:148)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor
.java:93)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterce
ptor.java:235)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDriven
Interceptor.java:89)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(Scope
dModelDrivenInterceptor.java:128)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(Profilin
gActivationInterceptor.java:104)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(Debuggin
gInterceptor.java:267)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterc
eptor.java:126)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.ja
va:148)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterc
eptor.java:138)
    at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilt
erInterceptor.java:87)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigI
nterceptor.java:164)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.
java:128)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(Except
ionMappingInterceptor.java:176)
    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:236)
    at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
    at
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperatio
ns.java:77)
    at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(S
trutsPrepareAndExecuteFilter.java:76)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilt
erChain.java:235)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.
java:206)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2
33)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:1
91)
    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:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Pr
otocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
Hibernate: select user0_.USER_ID as USER1_0_, user0_.USER_ABOUT_YOU as
USER2_0_, user0_.USER_COUNTRY as USER3_0_, user0_.USER_GENDER as USER4_0_,
user0_.USER_MAILING_LIST as USER5_0_, user0_.USER_NAME as USER6_0_,
user0_.USER_PASSWORD as USER7_0_ from USER user0_

-----------------------------
Kindly help me out.

Original issue reported on code.google.com by freekes...@gmail.com on 22 Aug 2009 at 2:06

GoogleCodeExporter commented 8 years ago
Does your configuration package extends "hibernate-default"?

Like this:

<package name="main" extends="hibernate-default">

        <action name="savePlayer" class="com.vaannila.web.UserAction" method="add">
            <result name="input">xxx.jsp</result>
            <result>yyy.jsp</result>
        </action>
...

Original comment by jyoshiriro on 25 Aug 2009 at 4:31

GoogleCodeExporter commented 8 years ago
Fixed in 1.4 GA 

Original comment by jyoshiriro on 24 Sep 2009 at 3:20