Obtaining already serialized objects

Hi All,
In my previous release of an application i used to serialize objects of a particular class say A.class
Now i have a new release of my application in which the class A has been changed. Now if I try to read the already serialized objects, it give ClassCastException.
I don't want to loose the old information inside already serialized objects of Old Version. But want to read them and write the full file again with the new Class A objects.
Any suggestion??
Thanks in Advance,
Manjinder Singh

Hi All,
In my previous release of an application i used to
serialize objects of a particular class say A.class
Now i have a new release of my application in which
the class A has been changed. Now if I try to read the
already serialized objects, it give
ClassCastException.
I don't want to loose the old information inside
already serialized objects of Old Version. But want to
read them and write the full file again with the new
Class A objects.
Any suggestion??
Thanks in Advance,
Manjinder SinghYes, read the tutorial. The solution is suggested there.

Similar Messages

  • A General serialized object

    Hi!
    I'm trying to create some server software that will allow any number of applets to connect to the server and communicate with each other. Presumably, only applets of the same type would talk together, though applets could send general string messages. I've created a general serialized object, Packet, which all applets would send to the server, and which the server would then pass on to the destination applet(s).
    The problem is that Packet has a field "data" of type Object. When data is something the server knows about, such as a String or a Vector, it does ok. But if the code for the applets creates a new class, say AppletPacket (which is serializable), and sets somePacket.data to an object of type AppletPacket, the server throws errors when it is reading the somePacket from its objectinputstream, saying it can't typecast something of type AppletPacket. But I'm not typecasting anywhere! The server doesn't have to know anything about what data represents, it just needs to send it on, and presumably the destination applets will know what to do with it.
    Can anyone suggest a work around, or tell me what I have to do so that applets can send a general Object that may represent a class the server doesn't know about and not have the server throw an error?
    Thanx
    Jim D.

    Just to clairify: The server doesn't have to do anything with the content of "data" apart from holding on to it, and pass it to another applet?
    If that's the case substitute the Object in the "data" field for an array of bytes obtained by having the applet run the "Object" through ObjectOutputStream.
    What's happening is that the server is deserializing the Packet when it arrives in the JVM of the server, when it comes across the "data" field it looks to see what class the instance really is, and fails as you dscribe if it doesn't have the class definition.

  • Direct DB access from Session Bean w/o using Serialized Objects

    I am developing a system where I am receiving some messages (data ) inside session bean and I want to log that data into data base �.i.e inserting that data in to various tables. I am not showing that data to client ( that is taken care by another application).
    So I am directly calling insert methods on various tables instead of going for serialized classes for each of that tables and calling setter methods. Is this approach correct? Or this will create nightmares when millions of messages are to be logged? Do I have to make serialized objects? Please post the suggestions ..Thank you in advance.
    If session bean is making direct inserts in the DB using Helper classes as shown below �is there any problem of concurrency?? Means multiple session bean instances inserting data in the same table using the helper class will create any problems?? I am using MySql db presently. Or all will work fine coz I am using the data source and pool available in welogic app server?
    Is this a good approach if my application is doing inserts 90% of times? or I have to use entity beans or serialized objects encapsulating each class?
    public class Logger implements SessionBean
    DAO dao = getDAO();
    dao.insertXyzLog(�x�, �y�,�.);
    private DAO getDAO(){
    if(Dao == null) {
    oao = DAOFactory.getDAO();
    return Dao;
    //other std methods
    public interface DAO {
    // methods to directly insert data in to the tables
    //some methods to look for required value in another tables
    public abstract void insertXyzLog (String x, Stringy, ���.);
    public class DAOImpl implements DAO {
    // look up for JNDI data sourse
    //method to return connection
    public void insertXyzLog (String x, Stirng y�){
    //SQLs for inserting into Xyz table using connection obtained above.

    Hi,
    Nothing wrong in using Helper class to insert into table. It won't create problem as long as your database server able to handle that many request from client.
    If you use weblogic server and datasource, the server will take care of all connection pool management depending upon your configuration parameters.
    Moreover, insert won't lock the table. So you need not worry about those things.
    Best Luck,
    Senthil Babu
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Why am I getting "There is already an object named '#TempTable...' in the database." within my SQL Server IF Statement

    The creation of My #TempTable is based on my input Parameter and I am getting "There is already an object named '#TempTable_Service_X_Claims' in the database." Why???
    USE [Report]
    GO
    DECLARE @ProviderType CHAR(1)
    SET @ProviderType = 'G'
    IF Object_ID('TempDB..#TempTable_Service_X_Claims') IS NOT NULL DROP TABLE [#TempTable_Service_X_Claims]
    IF @ProviderType = 'I'
    BEGIN
    SELECT...
    INTO [#TempTable_Service_X_Claims]
    FROM [dbo].[service_x]
    LEFT JOIN [dbo].[affiliation]
    ON [affiliation].[AFF_NBR] = [service_x].[AFF_NBR]
    AND [affiliation].[PROV_NBR] = [service_x].[Prov_Nbr]
    AND [affiliation].[VOID] = ''
    AND [affiliation].[c_ymdeff] <= [service_x].[C_EFF_DATE]
    AND [affiliation].[c_ymdend] >= [service_x].[C_EFF_DATE]
    WHERE [service_x].[C_EFF_DATE] >= '1/1/2013'
    AND [service_x].[C_EFF_DATE] <= '12/31/2013' --AND [affiliation].[PRAC_NBR] = @PracticeNbr
    AND [affiliation].[PRAC_NBR] = 'F330'
    END
    -- THEREFORE, USE THIS QUERY FOR "G" GROUP SELECTION SINCE IT USES [NPI]
    IF @ProviderType = 'G'
    BEGIN
    SELECT...
    INTO [#TempTable_Service_X_Claims]
    FROM [dbo].[service_x]
    LEFT JOIN [dbo].[affiliation]
    ON [affiliation].[AFF_NBR] = [service_x].[AFF_NBR]
    AND [affiliation].[PROV_NBR] = [service_x].[Prov_Nbr]
    AND [affiliation].[VOID] = ''
    AND [affiliation].[c_ymdeff] <= [service_x].[C_EFF_DATE]
    AND [affiliation].[c_ymdend] >= [service_x].[C_EFF_DATE]
    WHERE [service_x].[C_EFF_DATE] >= '1/1/2013'
    AND [service_x].[C_EFF_DATE] <= '12/31/2013'
    AND [affiliation].[NPI] = '1700947884 '
    END
    Thanks in advance for your review and am hopeful for a reply.
    PSULionRP

    The creation of My #TempTable is based on my input Parameter and I am getting "There is already an object named '#TempTable_Service_X_Claims' in the database." Why???
    USE [Report]
    GO
    DECLARE @ProviderType CHAR(1)
    SET @ProviderType = 'G'
    IF Object_ID('TempDB..#TempTable_Service_X_Claims') IS NOT NULL DROP TABLE [#TempTable_Service_X_Claims]
    IF @ProviderType = 'I'
    BEGIN
    SELECT...
    INTO [#TempTable_Service_X_Claims]
    FROM [dbo].[service_x]
    LEFT JOIN [dbo].[affiliation]
    ON [affiliation].[AFF_NBR] = [service_x].[AFF_NBR]
    AND [affiliation].[PROV_NBR] = [service_x].[Prov_Nbr]
    AND [affiliation].[VOID] = ''
    AND [affiliation].[c_ymdeff] <= [service_x].[C_EFF_DATE]
    AND [affiliation].[c_ymdend] >= [service_x].[C_EFF_DATE]
    WHERE [service_x].[C_EFF_DATE] >= '1/1/2013'
    AND [service_x].[C_EFF_DATE] <= '12/31/2013' --AND [affiliation].[PRAC_NBR] = @PracticeNbr
    AND [affiliation].[PRAC_NBR] = 'F330'
    END
    -- THEREFORE, USE THIS QUERY FOR "G" GROUP SELECTION SINCE IT USES [NPI]
    IF @ProviderType = 'G'
    BEGIN
    SELECT...
    INTO [#TempTable_Service_X_Claims]
    FROM [dbo].[service_x]
    LEFT JOIN [dbo].[affiliation]
    ON [affiliation].[AFF_NBR] = [service_x].[AFF_NBR]
    AND [affiliation].[PROV_NBR] = [service_x].[Prov_Nbr]
    AND [affiliation].[VOID] = ''
    AND [affiliation].[c_ymdeff] <= [service_x].[C_EFF_DATE]
    AND [affiliation].[c_ymdend] >= [service_x].[C_EFF_DATE]
    WHERE [service_x].[C_EFF_DATE] >= '1/1/2013'
    AND [service_x].[C_EFF_DATE] <= '12/31/2013'
    AND [affiliation].[NPI] = '1700947884 '
    END
    Thanks in advance for your review and am hopeful for a reply.
    PSULionRP
    Is it possible that this procedure is being executed more than once concurrently (even against different databases)) within the instance?
    Microsoft SQL Server Storage Engine PM

  • If I have my product code and cd for Adobe Creative Suite 5 can I obtain the serial number?

    If I have my product code and cd for Adobe Creative Suite 5 can I obtain the serial number? I had the serial number on my college email which I can't access now that I've graduated.

    adobe support might be able to help you,
    contact adobe support, https://helpx.adobe.com/contact.html

  • FileUpload problem: InputStream does not contain a serialized object

    Hi All,
    I'm using the FileUpload component in a JSPDynPage and the htmlb component seems to work fine but I cannot read the file (InputStream). I get the following error(IOException): "InputStream does not contain a serialized object".
    Please let me know what is wrong with my code. This is a part of the code I used:
    public FileInputStream sourceFileInput;
    public ObjectInputStream input;
    FileUpload fu;
    fu = (FileUpload) this.getComponentByName("myFileUpload");
    IFileParam fileParam = ((FileUpload) getComponentByName("myFileUpload")).getFile();
    File f       = fileParam.getFile();
    file         = fu.getFile().getFile();
    absolutepath = fu.getFile().getFile().getAbsolutePath();
    this.sourceFileInput = new FileInputStream(file);
    input = new ObjectInputStream(sourceFileInput);
    The last line of code seems to generate te error.

    Hi,
    I have found the answers, thank you both.
    (I included the examle code. Perhaps of some use to someone.)
    FileUpload fu;
    fu = null;
    fu = (FileUpload) this.getComponentByName("myFileUpload");
    //       this is the temporary file
    if (fu != null) {
         IFileParam fileParam = ((FileUpload) getComponentByName("myFileUpload")).getFile();
         if (fileParam != null) {
              // get info about this file and create a FileInputStream
              File f = fileParam.getFile();
              if (f != null) {
                   try {
                        fis = new FileInputStream(f);
                   // process exceptions opening files
                   catch (FileNotFoundException ex) {
                        myBean.setMessage(
                             "1" + f + ex.getLocalizedMessage());
                   isr = new InputStreamReader(fis);
                   br = new BufferedReader(isr);
    String textLine = "";
    do {
         try {
              textLine = (String) br.readLine();
         } catch (IOException e) {
              myBean.setMessage(
                   "1" + e.getLocalizedMessage());
         // Jco append table & put data into the record
         // (I_FILE is the table with txt data that is sent to the RFC)
         I_FILE.appendRow();     
         I_FILE.setValue(textLine, "REC");                              
    } while (textLine != null);

  • StreamCorruptedException: does not contain a serialized object?

    Can someone tell me why am I getting this exception:
    C:\javapr>java FetchObject
    Couldn't retrieve binary data: java.io.StreamCorruptedException: InputStream
    does not contain a serialized object
    java.io.StreamCorruptedException: InputStream does
    not contain a serialized object
    at java.io.ObjectInputStream.readStreamHeader
    (ObjectInputStream.java:849)
    at java.io.ObjectInputStream.<init>
    (ObjectInputStream.java:168)
    at FetchObject.main(FetchObject.java:23)
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    class FetchObject implements Serializable {
        public static void main (String[] args) {
            try {
                String driver = "oracle.jdbc.driver.OracleDriver";
                Class.forName(driver);
                String url = "jdbc:oracle:thin:@mymachine:1521:homedeva";
                Connection conn = DriverManager.getConnection(url,"cnn","cnn");
                FetchObject i = new FetchObject();
                    // Select related
                    try
                         byte[] recdBlob = i.selectBlob( 1 , conn ); 
                         ByteArrayInputStream bytes = new ByteArrayInputStream(recdBlob);
                         ObjectInputStream deserialize = new ObjectInputStream( bytes );
              Employee x = (Employee)deserialize.readObject();
                    catch( Exception ex )
                  System.err.println("Couldn't retrieve binary data: " + ex);
                  ex.printStackTrace();
         catch( Exception ex )
              ex.printStackTrace();
        public byte[] selectBlob( int id, Connection conn )
         byte[] returndata = null;
         try
              Statement stmt = conn.createStatement();
              String sql = "SELECT id, rowdata FROM blobs WHERE id = " + id;
              ResultSet rs = stmt.executeQuery(sql);
              if ( rs.next() )
                           try
                               ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
                               BufferedInputStream bis = new BufferedInputStream( rs.getBinaryStream("rowdata") );
                             byte[] bindata = new byte[4096];
                               int bytesread = 0;
                               if ( !rs.wasNull() )
                                       if ( (bytesread = bis.read(bindata,0,bindata.length)) != -1 )
                                          baos.write(bindata,0,bytesread);
                                returndata = baos.toByteArray();
                             baos.flush();
                                bis.close();
                       catch ( Exception ex )
                            System.err.println("Problem retrieving binary data: " + ex);
                        rs.close();
                         stmt.close();  
               catch ( Exception ex )
                    System.err.println("Couldn't retrieve binary data: " + ex);
            return returndata;
    import java.io.*;
    class Employee implements Serializable
         private String lastName;
         private String firstName;
         public Employee(String lastName, String firstName)
              this.lastName = lastName; 
              this.firstName = firstName;
    }

    To clarify I have stored an Employee Object as a Blob in the Oracle database and am attempting to retreive the
    Employee Object from this Blob.
    Thanks

  • Java.io.StreamCorruptedException: InputStream does not contain a serialized object

              I have an applet which calls a JSP to write data object to the db and then the
              JSP sends back the updated data object. The writing part is ok but the response
              is giving the following error. The data object is in a separate class which implements
              Serialized.
              Here's the code in the applet calling the JSP and the response from the JSP
              URL server = null;
              String urlConnectionString = "http://localhost:7001/isLoginValid.jsp";
              try
              server = new URL(urlConnectionString);
              catch(MalformedURLException e)
              System.out.println("URL exception: " + e );
              // send request
              ObjectInputStream response = null;
              Object result = null;
              try
              URLConnection conn = server.openConnection();
              conn.setDoOutput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "application/octet-stream");
              ObjectOutputStream request = new ObjectOutputStream(new
              BufferedOutputStream(conn.getOutputStream()));
              request.writeObject((Object)dvo);
              request.flush();
              request.close();
              // get the result input stream
              response = new ObjectInputStream(new BufferedInputStream
              (conn.getInputStream()));
              // read response back from the server
              result = response.readObject();
              if( result!=null && (result instanceof DataVO))
              dvo = (DataVO)result;
              String vo = dvo.printDataVO();
              System.out.println("*DataVO*\n"+vo);
              else
              System.out.println("not an instanceof DataVO");
              catch(IOException ignored)
              System.out.println("Error in DataVO response");
              ignored.printStackTrace();
              Here's the code in the JSP sending the response back to the applet. The 'dvo'
              object is the object which is serialized and has gets and sets for the diff. data
              elements. When I print the 'dvo' before writing the object to outputStream it
              prints the correct values for the data element.
              // send response
              response.setStatus(HttpServletResponse.SC_OK);
              ObjectOutputStream outputStream = new ObjectOutputStream (new BufferedOutputStream
              (response.getOutputStream()));
              outputStream.writeObject(dvo);
              outputStream.flush();
              ERROR is as follows:
              Error in DataVO response
              java.io.StreamCorruptedException: InputStream does not contain a serialized object
              at java/io/ObjectInputStream.readStreamHeader
              at java/io/ObjectInputStream.<init>
              What am I doing wrong?. Please respond soon. The applet is run on IIS and the
              JSP in on weblogic 6.1. I'm not sure if that makes any difference.
              

              I have an applet which calls a JSP to write data object to the db and then the
              JSP sends back the updated data object. The writing part is ok but the response
              is giving the following error. The data object is in a separate class which implements
              Serialized.
              Here's the code in the applet calling the JSP and the response from the JSP
              URL server = null;
              String urlConnectionString = "http://localhost:7001/isLoginValid.jsp";
              try
              server = new URL(urlConnectionString);
              catch(MalformedURLException e)
              System.out.println("URL exception: " + e );
              // send request
              ObjectInputStream response = null;
              Object result = null;
              try
              URLConnection conn = server.openConnection();
              conn.setDoOutput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "application/octet-stream");
              ObjectOutputStream request = new ObjectOutputStream(new
              BufferedOutputStream(conn.getOutputStream()));
              request.writeObject((Object)dvo);
              request.flush();
              request.close();
              // get the result input stream
              response = new ObjectInputStream(new BufferedInputStream
              (conn.getInputStream()));
              // read response back from the server
              result = response.readObject();
              if( result!=null && (result instanceof DataVO))
              dvo = (DataVO)result;
              String vo = dvo.printDataVO();
              System.out.println("*DataVO*\n"+vo);
              else
              System.out.println("not an instanceof DataVO");
              catch(IOException ignored)
              System.out.println("Error in DataVO response");
              ignored.printStackTrace();
              Here's the code in the JSP sending the response back to the applet. The 'dvo'
              object is the object which is serialized and has gets and sets for the diff. data
              elements. When I print the 'dvo' before writing the object to outputStream it
              prints the correct values for the data element.
              // send response
              response.setStatus(HttpServletResponse.SC_OK);
              ObjectOutputStream outputStream = new ObjectOutputStream (new BufferedOutputStream
              (response.getOutputStream()));
              outputStream.writeObject(dvo);
              outputStream.flush();
              ERROR is as follows:
              Error in DataVO response
              java.io.StreamCorruptedException: InputStream does not contain a serialized object
              at java/io/ObjectInputStream.readStreamHeader
              at java/io/ObjectInputStream.<init>
              What am I doing wrong?. Please respond soon. The applet is run on IIS and the
              JSP in on weblogic 6.1. I'm not sure if that makes any difference.
              

  • Hi,  I lost my serial number for PS Elements11 following computer crash. Os is W7. I have the cd installation disc but there is no serial number with it or in the envelope  ..  How can I obtain the serial number please?     Thanks

    I lost my seriel number for PS Elements 11 following computer crash. Os is W7
    Peter Jones Aug 27, 2014 5:36 AM   
    Hi,
    I lost my serial number for PS Elements 11 following computer crash. Os is W7. I have the cd installation disc but there is no serial number with it or in the envelope
    How can I obtain the serial number please?
    Thanks

    If you registered the software you should be able to find the serial number thru your Adobe account online.
    To locate the serial number:
    http://helpx.adobe.com/x-productkb/global/find-serial-number.html

  • Creating a converter for old serialized objects

    Hi,
    I have an application, which writes class objects to file, and then reads the class objects from file when the application is started up.
    Now the problem is, that if i create/modify/etc fields in the class, then all my data is lost (i.e., i cant read the data in when the application starts)....
    Now the docs state that a field can be added, and an old serialized object will still be recoverable...well for some reason this only works when it wants....i have tried several times, and its not a guarenteed thing....
    So i was wondering, is there any way to create an application, which can grab an old serialized version of an object (i.e. class), have a copy of the old class, and the new class, and somehow cast the old to the new...or something of that sort?
    thanks a lot!

    This might be of some help:
    http://www.onjava.com/pub/a/onjava/excerpt/JavaRMI_10/?page=5

  • How to divide big serialized object in parts to be able to save as Blob typ

    Hi,
    Actually i have serialize a big XML document object and want to save in a field of type Blob. As Blob size is 64k. So if the serialized object is greater than 64k. It gives me error of size.Can anybody tell how to break large serialized objects.
    I am using this code
    File f = new File("out.ser");
    FileInputStream fin = new FileInputStream(f);
    p = farCon.prepareStatement("insert into TeeColor values('3',?)");
    p.setBinaryStream(1, fin, f.length());
    p.executeUpdate();
    This code works fine if the size of out.ser file is less than 64k. But does not work for bigger sizes
    Please help me out
    Thanks

    Read your data from the file into a byte array, then extract 64K at a time into a smaller byte array, and use a ByteArrayInputStream for updating the database.

  • My redemption cod is not working so I cannot obtain my serial number. What am I supposed to do now?

    My redemption code is not working so I cannot obtain my serial number. What am I supposed to do now?

    hello, other users with this problem all had an embedded intel hd3000 graphics card with an old driver present. in case this also applies to you, here would be a link to update the driver, which in turn should also address the black firefox problem: https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=23764 (for win7 64 bit)

  • Problem with serialized objects and JWS

    My JWS launched application fails when loading a serialized object that has been instatiated from a class not contained in the signed jar-file. Does anyone know why this happens and if there is some workaround for the problem?

    Where is the class contained then?

  • OID and binding java serialized object

    Hi there,
    How are you doing? I am trying to bind a serialized java object to a name in Oracle Internet Diectory (oid) using JNDI.
    it gives me an errror.
    "OperationNotSupported LDAPA error 53: Unwilling to perform:
    I have directory manager 2.1.1 and JNDI 1.2.1
    I arrpeciate any clue and/or help
    Thanks
    null

    Hello:
    Although OID supports calls from JNDI, the JNDI schema for storing JAVA serialized objects is not yet a standard part of the OID schema. This is easy to remedy. Go to javasoft.sun.com and download the JNDI schema for java serialized objects and load the attributes and objectclasses into OID from the ldif files provided at this web site. . Make sure the attributes are loaded before the objectclasses.
    Once this schema is loaded this problem should go away
    Use the ldapmodify command line tool to add the schema items from the ldif file.
    Let me know if you need further assistance setting this up. A future version of OID will contain these schema items standard.
    Thanks,
    Jay
    null

  • I lost my serial number for photoshop elements11 and premiere elements 11 combo.  how can I obtain a serial number for this program?

    I lost my serial number for photoshop elements11 and premiere elements 11 combo.  how can I obtain a serial number for this program?

    If you registered the software you should be able to find the serial number thru your Adobe account online.
    To locate the serial number:
    http://helpx.adobe.com/x-productkb/global/find-serial-number.html

Maybe you are looking for

  • HT2822 APPLE TV & AIRPORT TIME CAPSULE

    Can I connect Apple TV via ethernet to my Apple Extreme ethernet LAN port to create a wi-fi area using the Apple TV device? or do I need to: Connect a second Time capsule and connect via Ethernet LAN i.e. 2 Airport Extremes connected via Lan Ethernet

  • Transfer music from friend ipod to my ipod

    transfer music from my friend ipod to may ipod

  • Eagle eyes web not working iOS 6

    i updated my iphone 3g to ios 6, i have a problem because eagle eyes web not working, appear message that push video is not compatible

  • Read Receipts and Conversations

    It would be great if we could get read receipts included with conversations. For instance, if I send an email with a subject of "Project Update", I get a read receipt that's titled "Read: Project Update". The receipt isn't included in the conversatio

  • Function module in R/3

    Hi Experts, I have 4 tables in R/3. and the relation is MKPF-MBLNR = MSEG-MBLNR & MSEG-MATNR ( Leftouterjoin) = MBEW-MATNR & MSEG-MATNR=(Leftoutre join) MARA-MATNR. with these relation i need to get around 20 firleds from these tables to BW ODS so i