I got a strange behaviour by using hibernate validators:
I take that:
In my entity-Bean, I use the hibernate-validator-tags:
Code:
@Length(min=4)
@NotNull(message="No Password")
@Column(name = "PASSWORD", nullable = false)
public String getPassword() { return password; }
I integrated the validator in an xhtml-page by using the Seam-Tag <s:validate/>. I got the following exception:
Code:
...
Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:605)
... 46 more
Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: Entity.Persons
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
... 51 more
Caused by: org.hibernate.validator.InvalidStateException: validation failed for: Entity.Persons
at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:143)
at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:167)
at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:156)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:49)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
... 56 more
...
The strange thing is, when I use the Tag "@Length" instead of "@NotNull" or "@NotEmpty", than my page with the hibernate validations works well.
Code:
@Length(min=1)
@Column(name = "PASSWORD", nullable = false)
public String getPassword() { return password; }
Why is that so? I wanna use @NotNull or @NotEmpty. to validate, that the field 'password' does not be empty. What is wrong?
nimo