2

I am using Spring MVC and Spring Security and hibernate. i am having problem with save 'Password" can not tell where mistake is

I get the Following Error When i submit my form

nested exception is javax.validation.ConstraintViolationException: Validation failed for classes [com.greensungh.jupiter_SHM.model.UsersInfo] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
    ConstraintViolationImpl{interpolatedMessage='size must be between 6 and 25', propertyPath=Password, rootBeanClass=class com.greensungh.jupiter_SHM.model.UsersInfo, messageTemplate='{javax.validation.constraints.Size.message}'}
]] with root cause
javax.validation.ConstraintViolationException: Validation failed for classes [com.greensungh.jupiter_SHM.model.UsersInfo] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
    ConstraintViolationImpl{interpolatedMessage='size must be between 6 and 25', propertyPath=Password, rootBeanClass=class com.greensungh.jupiter_SHM.model.UsersInfo, messageTemplate='{javax.validation.constraints.Size.message}'}

this is my view:

<div class="control-group">
<label class="control-label" for="password">Password</label>
<div class="controls">
<form:password path="Password" id="password"
class="form-control span8" />
<div class="has-error">
<form:errors path="Password" class="help-inline" />
</div></div></div>  

The Model:

@NotEmpty
    @Size(min=6, max=25)
    @Column(name="PASSWORD", nullable=false)
    private String Password;

my messages.properties

NotEmpty.userInfo.Password=Password must be blank
Size.userInfo.Password=Password must be between {6} to {25} characters long

any ideas

1 Answer 1

7

I had the same issue. The problem was I set the password max to 30 and at the same time I used bcrypt encoder. Bcrypt hashes the password and store it as a random 60 characters which violates the max size constraints. So if you are using an encryption increase you max so your encrypted password meets the size requirement. I hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.