Hello
this is my validator rule. I verify that the email insert by an user is still present in the database.
Code:
public static boolean emailPresent (Object bean, ValidatorAction va, Field field, ActionMessages errors,
Validator validator, HttpServletRequest request) {
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
Query query = OQLHelper.createQuery("from "+JncvLogin.class.getName()+" as jl where jl.desEmail = :email");
query.setString("email",value);
if(query.uniqueResult()!=null){
System.out.println("EMAIL FOUND");
return true;
}
errors.add(field.getKey(), Resources.getActionMessage(request, va, field));
System.out.println("EMAIL NOT FOUND");
return false;
}
If the user input a "non present" email ther're non errors in console.
If the user input a email and this is found in the db the console says me this
Code:
11:15:59,189 ERROR [ValidatorAction] Unhandled exception thrown during validation: could not deserialize
org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:211)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:234)
at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:78)
at org.hibernate.type.SerializableType.get(SerializableType.java:39)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1680)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:958)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:909)
at org.hibernate.loader.Loader.getRow(Loader.java:822)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:297)
at org.hibernate.loader.Loader.doQuery(Loader.java:395)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.doList(Loader.java:1562)
at org.hibernate.loader.Loader.list(Loader.java:1545)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:840)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)
at com.sintesinet.jobnet.cv.validator.PswRcvValidator.emailPresent(PswRcvValidator.java:40)
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 org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:567)
at org.apache.commons.validator.Field.validateForRule(Field.java:827)
at org.apache.commons.validator.Field.validate(Field.java:906)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:110)
at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.sintesinet.common.persistence.PersistenceFilter.doFilter(PersistenceFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
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.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
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:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:246)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:203)
... 59 more
11:16:11,706 WARN [JDBCContext] afterTransactionCompletion() was never called
11:16:11,706 WARN [JDBCContext] unclosed connection, forgot to call close() on your session?
so.. if the email is not found: no deserialized exception
if it's found the console says SerializationException: could not deserialize
what's the problem??? file mapping are well done by hibernateTools.
I don't understand..
thx
all the file are generated with Hibernate Tools
this is the file mapping
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 9-mag-2006 12.18.37 by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="com.sinte.cv.persistence.jncv.JncvLogin" table="JNCV_LOGIN" schema="JNCV">
<id name="cdaAnag" type="integer">
<column name="CDA_ANAG" precision="8" scale="0" />
<generator class="assigned" />
</id>
<property name="desUtente" type="string">
<column name="DES_UTENTE" length="30" />
</property>
<property name="desPassword" type="string">
<column name="DES_PASSWORD" length="30" />
</property>
<property name="dtmRegistrazione" type="serializable">
<column name="DTM_REGISTRAZIONE" />
</property>
<property name="desEmail" type="string">
<column name="DES_EMAIL" length="50" />
</property>
<property name="desDomanda" type="string">
<column name="DES_DOMANDA" length="80" />
</property>
<property name="desRisposta" type="string">
<column name="DES_RISPOSTA" length="50" />
</property>
<property name="desCodiceFiscale" type="string">
<column name="DES_CODICE_FISCALE" length="16" />
</property>
<property name="dtmRegistrazioneOracle" type="timestamp">
<column name="DTM_REGISTRAZIONE_ORACLE" length="7" />
</property>
<property name="desSitoProvenienza" type="string">
<column name="DES_SITO_PROVENIENZA" length="200" />
</property>
<set name="jncvAssAnagCurrics" inverse="true">
<key>
<column name="CDA_ANAG" precision="8" scale="0" not-null="true" />
</key>
<one-to-many class="com.sinte.cv.persistence.jncv.JncvAssAnagCurric" />
</set>
</class>
</hibernate-mapping>
Please help me ... ??? ... !!
thanks a lot for all guys
;)