-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Validator thrown InvalidStateException for @Email
PostPosted: Sat Jan 06, 2007 9:48 am 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
Hi.

I have in my entity class the @Email hibernate validator annotation for an email property:

Code:
@Entity
@Table(name = "users")
@Name("user")
@Scope(ScopeType.EVENT)
public class User implements Serializable{
...
   @Email
    @Length(max=50)
    private String email;
...
}


In the JSF page the email is not required (I'm using Seam <s:validateAll>).

But when I don't enter an email into the JSF form (leave empty) I always get the exception:
org.hibernate.validator.InvalidStateException: validation failed for: User

There is no error if I enter an email in the inputText field.


Is there something I'm doing wrong?
The @Email validator only works for not null (required) fields?

Any help will be appreciated...

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 06, 2007 12:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Email does not requires non null property. What is the exact stacktrace

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 06, 2007 6:12 pm 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
The full stacktrace is:

Code:
javax.ejb.EJBTransactionRolledbackException: org.hibernate.validator.InvalidStateException: validation failed for: com.jatun.jrbundler.domain.User
        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:93)
        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:201)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:189)
        at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
        at $Proxy51.create(Unknown Source)
        at com.jatun.jrbundler.action.UserManager$$FastClassByCGLIB$$9d570455.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
        at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
        at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:73)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
        at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
        at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
        at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
        at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
        at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
        at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
        at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
        at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
        at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:82)
        at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:51)
        at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$85b4c4fa.create(<generated>)
        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:585)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
        at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
        at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
        at javax.faces.component.UICommand.broadcast(UICommand.java:106)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
        at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
        at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(BlockingServlet.java:435)
        at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(BlockingServlet.java:423)
        at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:277)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.validator.InvalidStateException: validation failed for: com.jatun.jrbundler.domain.User
        at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:104)
        at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:127)
        at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:139)
        at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:44)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
        at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:267)
        at org.jboss.ejb3.entity.TransactionScopedEntityManager.flush(TransactionScopedEntityManager.java:204)
        at com.jatun.jrbundler.action.UserManagerAction.create(UserManagerAction.java:55)
        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:585)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
        at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:51)
        at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
        at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
        at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:23)
        at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
        at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
        at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
        at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
        at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
        at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
        at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
        at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
        ... 78 more




The JSF page portion is:

Code:
...
<s:validateAll>
...
<h:outputLabel for="email" value="#{messages['User.email']}"/>
    <s:decorate>
        <ice:inputText id="email" value="#{user.email}" maxlength="50"
                       tabindex="10" styleClass="input" partialSubmit="true" />
        <br/><s:message/>
    </s:decorate>
...
</s:validateAll>



When I add the attribute required="true" in the inputText, there is no exception , but I should have email as an optional field, not required.


Thanks for your help!.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You'll have to look at the InvalidStateException.getInvalidValues() for more info. The validator is not triggered by your JSF, but by Hibernate when the object is saved

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 18, 2007 2:02 pm 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
After inspecting the code and even writing my own EmailValidator I found the problem.
When I don't enable "required=true" in the JSF page, and I leave the field empty and submit the form that email property value is always sent as empty string (""), not as null.

So, adding below line to my own EmailValidator (isValid method) it works fine:
Code:
if(string.length() == 0) return true;



Now, my questions are:

a) Could it be a good idea to add that line to hibernate EmailValidator? (maybe it is good idea because an empty string will always return an error when validating).

b) Do you know why empty properties (String types) which are not required in the JSF page are sent as empty strings("") to backing objects? (maybe this is not the right forum to ask this, in that case what forum should I post?).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 7:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't know about b., but a. is a good idea
http://opensource.atlassian.com/projects/hibernate/browse/HV-3

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Same problem here
PostPosted: Thu May 17, 2007 8:39 am 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
I've got the same issue with @Email where it is an optional field. Can I vote for (a) of fernando's suggestion?

Thanks,

Damian.


Top
 Profile  
 
 Post subject: Re: Same problem here
PostPosted: Thu May 17, 2007 10:04 am 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
damianharvey wrote:
I've got the same issue with @Email where it is an optional field. Can I vote for (a) of fernando's suggestion?

Thanks,

Damian.



Damian, it is already solved:
http://opensource.atlassian.com/project ... rowse/HV-3

I guess you can get the 3.0.0.ga of Hibernate Validator and try it out.

_________________
Fer ©


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 2:48 am 
Newbie

Joined: Thu Apr 03, 2008 2:16 am
Posts: 4
We're using 3.0.0.ga of Hibernate Validator. But we still face the same problem. @Email is only usable with required fields. Empty fields raise:

Code:
Exception during request processing:
Caused by java.lang.IllegalStateException with message: "Could not commit transaction"

Caused by javax.transaction.RollbackException with message: "[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"

Caused by javax.persistence.PersistenceException with message: "org.hibernate.validator.InvalidStateException: validation failed for:

Caused by org.hibernate.validator.InvalidStateException with message:


Seam version is 2.0.1 GA. Tested on FF browser.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 9:24 am 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
Are you using the same version in you application server? can you ensure that?

Because in JBoss 4.2.2 the version is an old one. I checked it out.

_________________
Fer ©


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 11:00 am 
Newbie

Joined: Thu Apr 03, 2008 2:16 am
Posts: 4
Thank you now it works i've cleaned all default hibernate libraries under jboss lib. Only there was no seperate jar hibernate-validator-3.0.0.GA.jar like we deploy with our application. Which jar really holds validator classes:

hibernate3.jar
hibernate-annotations.jar
hibernate-entitymanager.jar

?

And won't it raise any issues if all hibernate jars are removed from jboss library?

Thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 11:12 am 
Newbie

Joined: Sat Jan 06, 2007 9:30 am
Posts: 12
Drlzzt wrote:
Which jar really holds validator classes:

hibernate3.jar
hibernate-annotations.jar
hibernate-entitymanager.jar

?



hibernate-annotations.jar

Drlzzt wrote:
And won't it raise any issues if all hibernate jars are removed from jboss library?


I don't know, you can try it. By my side I implemented the @Email validator in my own project in order to skip any issue.

_________________
Fer ©


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.