1 Reply Latest reply on Jul 14, 2003 3:56 AM by etktev

    java.lang.ClassCastException: org.jboss.invocation.Marshalle

    etktev

      I am having the problem of this exception occuring in some occasions
      (I couldn't found out under which circumstances) which I should solve somehow...
      It occurs in some modified DAO object called by one session bean. This EJB's method instantiates/calls some
      DAO object's method and try to fetch some data from MySQL database. Data types handled through
      the ResultSet are String,Timestamp and Object, and are actually stored in corresponding varchar,
      timestamp and longblob fields in database.
      I'm using JBoss 3.0.3, Mysql 3.23.55 and JDBC driver "MySql Connector 2.0.14".

      Is there some hint how whta could be wrong there...?

      Code & log_output & some config details look like:

      source - ejb part (in ejb which calls dao method)
      ------------------------------------------------------------

      PermissResponseCacheHandler prch = null;
      PermissResponseCacheDAO prchdao = null;

      try{
      prch = PermissResponseCacheHandler.getInstance();
      prchdao = prch.findByPrimaryKey(userid);
      CacheResponseMessage crm = prchdao.getClientmessage();
      retval = crm.getXmlMessage();
      } catch(Exception e){
      log.warning("ERROR in PermissResponseCacheWorkflow - updating in the PermissResponseCache (with 'entity bean') --> " + e.toString());
      }


      source - dao part (PermissResponseCacheHandler -
      singleton which returns DAO)
      ----------------------------------------------------------------

      public PermissResponseCacheDAO findByPrimaryKey(String userid) throws PermissResponseCacheDAOException{
      PermissResponseCacheDAO dao = null;
      try{
      dao = new PermissResponseCacheDAO();
      dao.findByPrimaryKey(userid);
      } catch(PermissResponseCacheDAOException e){
      throw e;
      }
      return dao;
      }


      source - dao part (PermissResponseCacheDAO - one of methods in DAO class)
      -------------------------------------------------------------

      protected void findByPrimaryKey(String userid) throws PermissResponseCacheDAOException{

      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;

      PermissResponseCacheDTO datarow = new PermissResponseCacheDTO();

      try{

      conn = connhandler.getConnection();

      String stmtString = "SELECT * FROM RESPONSECACHE WHERE USERID = ?";

      stmt = conn.prepareStatement(stmtString);

      stmt.setString(1, userid);

      rs = stmt.executeQuery();

      if(rs.first()){
      datarow.setUserid(rs.getString("USERID"));
      datarow.setLastdate(rs.getTimestamp("LASTDATE"));
      datarow.setCacheResponseMessage((CacheResponseMessage)rs.getObject("CLIENTMESSAGE"));
      log.info("********** Found row of data in table RESPONSECACHE - 'entity bean' initialization.");
      }
      else{
      log.info("********** Row of data in table RESPONSECACHE not found - 'entity bean' not initialized.");
      throw new PermissResponseCacheDAOException("Row of data in table RESPONSECACHE not found - 'entity bean' not initialized.");
      }

      } catch (Exception e){
      log.warning("********** Some exception while performing searching in database: " + e.toString());
      throw new PermissResponseCacheDAOException(e.toString() + "\n - Data row ('entity bean') not initialized.");
      }
      finally
      {
      try{
      if(conn != null) conn.close();
      if(stmt != null) stmt.close();
      } catch (SQLException e){
      log.warning("********** Sql exception while closing connection to database: " + e.toString());
      }
      conn = null;
      stmt = null;
      }
      this.datarow = datarow;
      }

      serialized object saved in one of fileds
      -------------------------------------------------
      public class CacheResponseMessage implements java.io.Serializable
      {

      private String xmlMessage;

      public CacheResponseMessage(){}

      public CacheResponseMessage(String xmlMessage)
      {
      this.xmlMessage = xmlMessage;
      }

      public String getXmlMessage()
      {
      return xmlMessage;
      }

      public void setXmlMessage(String xmlMessage)
      {
      this.xmlMessage = xmlMessage;
      }
      }


      log output
      ---------------
      2003-07-04 11:10:29,562 ERROR [STDERR] 2003.07.04 11:10:29 hr.ericsson.pzz.fm.business.ejb.PermissResponseCacheWorkflowBean respmsgfromcache
      WARNING: ERROR in PermissResponseCacheWorkflow - updating in the PermissResponseCache (with 'entity bean') --> java.lang.ClassCastException: org.jboss.invocation.MarshalledValue
      - Data row ('entity bean') not initialized.


      Config file "standardjbosscmp-jdbc.xml" in $JBOSS/server/default/conf has mappings for
      data ypes being stored&fetched in this case:
      ------------------------------------------------------------

      <java-type>java.lang.Object</java-type>
      <jdbc-type>BLOB</jdbc-type>
      <sql-type>LONGBLOB</sql-type>


      <java-type>java.sql.Timestamp</java-type>
      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>TIMESTAMP</sql-type>


      <java-type>java.lang.String</java-type>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(250) BINARY</sql-type>