0 Replies Latest reply on Jun 24, 2005 11:00 AM by Enzo Poeta

    org.hibernate.type.SerializationException: could not deseria

    Enzo Poeta Newbie

      Hi ! can anyome help with this problem ?

      here is my codes :


      /*
      * Created on Apr 26, 2004
      *
      * To change the template for this generated file go to
      * Window>Preferences>Java>Code Generation>Code and Comments
      */
      package ordemservico.beans.entity;

      /**
      * @author Enzo Telles Poeta
      *
      * To change the template for this generated type comment go to
      * Window>Preferences>Java>Code Generation>Code and Comments
      */
      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.Collection;


      import javax.persistence.AssociationTable;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.GeneratorType;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;

      @Entity
      @Table(name = "rkos01")
      public class Usuario implements Serializable
      {
      // Atributos
      private String nome;
      private String email;
      private int matricula;
      private CentroCusto ccusto;
      private String login;
      private Collection perfis;
      private boolean ativo;
      private int tipoUsuario;
      private Collection ccustos;
      private String passwordUsuario;


      //metodos

      // Collectiona os centros de custo para os quais o usuario pode solicitar Oss

      @OneToMany
      @AssociationTable(
      table=@Table(name="rkos60"),
      joinColumns = { @JoinColumn( name="id_usuar") },
      inverseJoinColumns = @JoinColumn( name="cd_ccust")
      )
      public Collection getCCustosAutorizados()
      {
      return ccustos;
      }

      // teste
      public void setCCustosAutorizados(Collection ccustos)
      {
      this.ccustos=ccustos;
      }

      // Collectiona os perfis que possui o usuario

      @OneToMany
      @AssociationTable(
      table=@Table(name="rkos80"),
      joinColumns = { @JoinColumn( name="id_usuar") },
      inverseJoinColumns = @JoinColumn( name="tip_perf")
      )
      public Collection getPerfis()
      {
      return perfis;
      }

      //teste2
      public void setPerfis(Collection perfis)
      {
      this.perfis=perfis;
      }

      // retorna o atributo password
      @Column(updatable = true, name = "pwd_usuar", nullable = false, length = 8)
      public String getPassword()
      {
      return passwordUsuario;
      }

      // retorna o atributo nome
      @Column(updatable = true, name = "nome_funcio", nullable = false, length = 40)
      public String getNome()
      {
      return nome;
      }

      // retorna o atributo Centro de Custo
      @Column(updatable = true, name = "cd_ccust", nullable = false, length = 5)
      public CentroCusto getCentroCusto()
      {
      return ccusto;
      }

      // retorna o atributo email
      @Column(updatable = true, name = "end_email", nullable = true, length = 40)
      public String getEmail()
      {
      return email;
      }

      // retorna o atributo matricula
      @Column(updatable = true, name = "num_matr_unicamp", nullable = true)
      public int getMatricula()
      {
      return matricula;
      }

      // retorna o atributo tipoUsuario
      @Column(updatable = true, name = "tp_funcio", nullable = true)
      public int getTipo()
      {
      return tipoUsuario;
      }

      // retorna o atributo Login
      @Id(generate = GeneratorType.NONE)
      @Column(updatable = true, name = "id_usuar", nullable = false, length = 7)
      public String getLogin()
      {
      return login;
      }

      // Retorna o atributo ativo
      @Column(updatable = true, name = "fl_ativ_funcio", nullable = false, length = 7)
      public boolean getStatus()
      {
      return ativo;
      }

      // seta o atributo nome
      public void setNome(String nomeUsuario)
      {
      this.nome=nomeUsuario;
      }

      // seta o atributo password
      public void setPassword(String password)
      {
      this.passwordUsuario = password;
      }

      // seta o atributo area
      public void setCentroCusto(CentroCusto ccusto)
      {
      this.ccusto=ccusto;
      }

      // seta o atributo email
      public void setEmail(String mail)
      {
      this.email=mail;
      }

      // seta o atributo matricula
      public void setMatricula(int codMatricula)
      {
      this.matricula=codMatricula;
      }

      // seta o atributo tipoUsuario
      public void setTipo(int codTipo)
      {
      this.tipoUsuario=codTipo;
      }

      // seta o atributo Login
      public void setLogin(String loginUsuario)
      {
      this.login=loginUsuario;
      }

      // Seta o atributo ativo
      public void setStatus(boolean estado)
      {
      this.ativo=estado;
      }


      // adiciona um novo centro de custo a Collectionagem
      public void adicionarCentroCustoAutorizado(CentroCusto ccusto)
      {
      if (ccustos == null)
      {
      ccustos = new ArrayList();
      }

      if (ccustos.contains(ccusto)==false)
      {
      ccustos.add(ccusto);
      }
      }

      // remove um centro de custo da Collectionagem
      public void removerCentroCustoAutorizado(CentroCusto ccusto)
      {
      if (ccustos == null)
      {
      ccustos = new ArrayList();
      }

      if (ccustos.contains(ccusto)==true)
      {
      ccustos.remove(ccusto);
      }
      }

      // adiciona um novo perfil ao usuario
      public void adicionarPerfil(Perfil perfil)
      {
      if (perfis == null)
      {
      perfis = new ArrayList();
      }
      if (perfis.contains(perfil)==false)
      {
      perfis.add(perfil);
      }
      }

      // Remove um perfil de usuario
      public void removerPerfil (Perfil perfil)
      {
      if (perfis == null)
      {
      perfis = new ArrayList();
      }
      if (perfis.contains(perfil)==true)
      {
      perfis.remove(perfil);
      }
      }

      }


      /*
      * Created on May 6, 2004
      *
      * To change the template for this generated file go to
      * Window>Preferences>Java>Code Generation>Code and Comments
      */
      package ordemservico.beans.entity;

      import java.io.Serializable;

      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratorType;
      import javax.persistence.Id;
      import javax.persistence.Table;


      /**
      * @author Enzo Telles Poeta
      *
      * To change the template for this generated type comment go to
      * Window>Preferences>Java>Code Generation>Code and Comments
      */


      @Entity
      @Table(name = "rkos90")
      public class CentroCusto implements Serializable
      {
      // Atributos
      private String codigoCCusto;
      private String emailResponsavel;
      private String descricaoCCusto;



      // metodos

      // retorna o atributo descricaoCCusto
      @Column(updatable = true, name = "dc_ccust", nullable = false, length = 40)
      public String getDescricaoCentroCusto()
      {
      return descricaoCCusto;
      }

      // retorna o atributo codigoCCusto
      @Id(generate = GeneratorType.NONE)
      @Column(updatable = true, name = "cd_ccust", nullable = false, length = 5)
      public String getCodigoCentroCusto()
      {
      return codigoCCusto;
      }

      // retorna o atributo emailResponsavel
      @Column(updatable = true, name = "end_email_resp", nullable = true, length = 40)
      public String getEmailResponsavel()
      {
      return emailResponsavel;
      }

      // seta o atributo emailResponsavel
      public void setEmailResponsavel(String email)
      {
      this.emailResponsavel=email;
      }

      // insere o atributo codigoCCusto
      public void setCodigoCentroCusto(String codCCusto)
      {
      this.codigoCCusto=codCCusto;
      }

      // seta o atributo descricaoCCusto
      public void setDescricaoCentroCusto(String descCCusto)
      {
      this.descricaoCCusto = descCCusto;
      }

      }




      /*
      * Created on 05/05/2004
      *
      */
      package ordemservico.beans.entity;

      import java.io.Serializable;

      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratorType;
      import javax.persistence.Id;
      import javax.persistence.Table;

      @Entity
      @Table(name = "rkos70")
      public class Perfil implements Serializable
      {
      // Atributos

      private String tipoPerfil;
      private String descricao;


      // metodos

      @Id(generate = GeneratorType.NONE)
      @Column(updatable = true, name = "tip_perf", nullable = false, length = 1)
      public String getId()
      {
      return tipoPerfil;
      }

      @Column(updatable = true, name = "dc_perf", nullable = false, length = 20)
      public String getDescricao()
      {
      return descricao;
      }

      public void setId(String tipoP)
      {
      this.tipoPerfil = tipoP;
      }

      public void setDescricao(String desc)
      {
      this.descricao = desc;
      }

      }


      package ordemservico.beans.stateful;

      import javax.ejb.Remote;
      import javax.ejb.Remove;

      import ordemservico.beans.entity.Usuario;

      @Remote
      public interface UserManagerRemote
      {
      public Usuario searchUser(String userName);
      @Remove public void remover();
      }



      package ordemservico.beans.stateful;

      import java.io.Serializable;
      import java.util.Collection;
      import java.util.Iterator;

      import javax.ejb.Inject;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import ordemservico.beans.entity.Usuario;

      @Stateful
      public class UserManagerBean implements UserManagerRemote,Serializable
      {

      private @Inject EntityManager manager;
      private Usuario usuario;



      @Remove
      public void remover()
      {
      //NAO FAZ NADA
      }

      public Usuario searchUser(String userName)
      {
      usuario =(Usuario)manager.createQuery("from Usuario usuario where usuario.login='"+userName+"'").getSingleResult();
      return usuario;
      }
      }


      when run the client that call UserManagerRemote i got the following messages :

      [java] log4j:WARN No appenders could be found for logger (org.jboss.remoting.Client).
      [java] log4j:WARN Please initialize the log4j system properly.
      [java] Exception in thread "main" org.hibernate.type.SerializationException: could not deserialize
      [java] at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:211)
      [java] at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:234)
      [java] at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:78)
      [java] at org.hibernate.type.SerializableType.get(SerializableType.java:39)
      [java] at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
      [java] at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
      [java] at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
      [java] at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1695)
      [java] at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:918)
      [java] at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:874)
      [java] at org.hibernate.loader.Loader.getRow(Loader.java:787)
      [java] at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:293)
      [java] at org.hibernate.loader.Loader.doQuery(Loader.java:387)
      [java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
      [java] at org.hibernate.loader.Loader.doList(Loader.java:1515)
      [java] at org.hibernate.loader.Loader.list(Loader.java:1498)
      [java] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
      [java] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
      [java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
      [java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
      [java] at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:588)
      [java] at org.jboss.ejb3.entity.QueryImpl.getSingleResult(QueryImpl.java:66)
      [java] at ordemservico.beans.stateful.UserManagerBean.searchUser(UserManagerBean.java:30)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] at java.lang.reflect.Method.invoke(Method.java:585)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:77)
      [java] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:134)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      [java] at org.jboss.aspects.tx.TxSupport.invokeInOurTx(TxSupport.java:141)
      [java] at org.jboss.aspects.tx.TxSupport$Required.serverInvoke(TxSupport.java:438)
      [java] at org.jboss.aspects.tx.TxInterceptor.internalInvoke(TxInterceptor.java:112)
      [java] at org.jboss.aspects.tx.TxInterceptor.invoke(TxInterceptor.java:60)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:80)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:90)
      [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      [java] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:156)
      [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
      [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:74)
      [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
      [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
      [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
      [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:327)
      [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
      [java] Caused by: java.io.StreamCorruptedException: invalid stream header
      [java] at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:753)
      [java] at java.io.ObjectInputStream.(ObjectInputStream.java:268)
      [java] at org.hibernate.util.SerializationHelper$CustomObjectInputStream.(SerializationHelper.java:246)
      [java] at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:203)
      [java] ... 48 more


      Thanks and sorry for the big message ....