-->
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.  [ 6 posts ] 
Author Message
 Post subject: SerializationException: could not deserialize
PostPosted: Thu May 11, 2006 5:23 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
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
;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 6:44 am 
Newbie

Joined: Wed Nov 23, 2005 5:01 am
Posts: 15
Hi,

I guess the problem is with your serializable property:
Quote:
<property name="dtmRegistrazione" type="serializable">
<column name="DTM_REGISTRAZIONE" />
</property


Is possible that for a valid email to not have a valid "dtmRegistrazione" in your database. Maybe is not a valid serializable stream.

Try to assure yourself that there is a valid serializable object into your DTM_REGISTRAZIONE column or try to eliminate for the moment that property to see if the error still appear.

I hope this help you

Calin[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 8:45 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
Hy calin!
Thanks a lot for the response!
I erase the

Code:
<property name="dtmRegistrazione" type="serializable">
            <column name="DTM_REGISTRAZIONE" />
        </property>


and now it works....

this column (DTM_REGISTRAZIONE) in my DB contains simple string like
20041025
20041204
...
these fields are for date I think.
I've not created the Db.. it has been created by other persons.
I don't know the definition Db tables and the Hibernate tools gives me the automatic mapping to a serializable type.

How does this error means? I must change the DB structure or something else?

Thanks a lot for your support
regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 9:03 am 
Newbie

Joined: Wed Nov 23, 2005 5:01 am
Posts: 15
Hi 6sic6,

It is not neccessary to modify the DB structure, but this depends of the actual structure of your DB. Maybe you can find out what is the current sql type of your DTM_REGISTRAZIONE column and to put the appropriate hibernate type in your mapping file for that property.

For example if your sql type for the column is DATE than you have to put instead serializable type the date type for that property:

<property name="dtmRegistrazione" type="date">
<column name="DTM_REGISTRAZIONE" />
</property>

and change your class definition to reflect the changes from mapping.

You have to change the structure of your DB only if the column type dose not correspond with the property type from your class and you want TO KEEP that specific property type into your class definition.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 10:54 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
Hy

The type on the DB is FLOAT(126)
I've seen that the Hibernate Tool generated all "serializable" type on the xml mapping for all the DB FLOAT(126) format.

It's this a bug or normal?
I don't want change the Db structure. So you say I must change to Float all the definition xml and the corrispective class?

thx


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 5:37 pm 
Newbie

Joined: Wed Nov 23, 2005 5:01 am
Posts: 15
Hi,

I didn't use the Hibernate tools for generating my mappings files, so I can't tell you if this is a bug or not. I like to write my mappings file or if I am in a hurry than I use xdoclet to generate them.

If you don't want to change the DB structure and you think that the Float is a good type for your needs than you can use it. And, yes you have to change the xml structure and the class for corresponding property.

_________________
I hope this help.
Calin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.