[Biojava-dev] [Bug 2359] New: SingleDP deserialization fails

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Sat Sep 8 23:02:38 UTC 2007


http://bugzilla.open-bio.org/show_bug.cgi?id=2359

           Summary: SingleDP deserialization fails
           Product: BioJava
           Version: 1.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: dist/dp
        AssignedTo: biojava-dev at biojava.org
        ReportedBy: daniel.rohrbach at web.de


it isn't possible to load an instance of SingleDP via serialization. SingleDP
which is serializable inherits from DP which is not serializable . Loading the
Object works well.

I used biojava 1.5 latest build 9/8/07 2:22 AM but the same exception occurs in
all 1.5 

the reason for the bug is that SingleDP extends DP which is not serializable. 
In that case it must implement a no args constructor but it doesn't!

Because of that the same should occur for PairwiseDP


the stack trace:

java.io.InvalidClassException: org.biojava.bio.dp.onehead.SingleDP;
org.biojava.bio.dp.onehead.SingleDP; no valid constructor
        at
java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713)
        at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at biojavabugs.SingleDBBug.main(SingleDBBug.java:92)
Caused by: java.io.InvalidClassException: org.biojava.bio.dp.onehead.SingleDP;
no valid constructor
        at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:471)
        at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)




and the code i used to cause the bug:



            //create the HMM
            ProfileHMM hmm = new ProfileHMM(ProteinTools.getAlphabet(),
                             12,
                             DistributionFactory.DEFAULT,
                             DistributionFactory.DEFAULT,
                             "biojava profile hmm");

            //create an SingleDP object which we want to save and load
            DP dp = (SingleDP) DPFactory.DEFAULT.createDP(hmm);

            try {

//
// saving
//
                // the filename
                File load = new File("/home/dani/Desktop/dp");

                FilePermission fp = new FilePermission(load.getAbsolutePath(),
"write");

                if(!load.createNewFile())
                {
                        throw new IOException("file '" + load.getAbsolutePath()
+ "' could not be created!");
                }

                FileOutputStream fos = new FileOutputStream(load);
                ObjectOutputStream oos = new ObjectOutputStream(fos);

                //store object to disk
                oos.writeObject(dp);

                oos.close();

//
// loading
//
                // try to load the SingleDP object

                fp = new FilePermission(
                       load.getAbsolutePath(), "read");


                FileInputStream fis = new FileInputStream(load);
                ObjectInputStream ois = new ObjectInputStream(fis);

                Vector<Object> v = new Vector<Object>();

                //here is where the EXCEPTION occurs
                Object o = ois.readObject();
                v.add(o);

                System.out.println("loaded Object!");
               // System.out.println(obj.toString());
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the biojava-dev mailing list