Ok, im gonna go ahead and just paste most of the stack trace in, (its massive) :


java.io.NotSerializableException: com.sun.java.swing.plaf.windows.XPStyle
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
at javax.swing.JComponent.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.awt.Container.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.awt.Container.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.awt.Container.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.awt.Container.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at saiman.quantgcms.QuantitationSessionManagementViewPerspectiveUI.saveSession(QuantitationSessionManagementViewPerspectiveUI.java:235)
at saiman.quantgcms.QuantitationSessionManagementViewPerspectiveUI.fileSave(QuantitationSessionManagementViewPerspectiveUI.java:147)
at saiman.quantgcms.QuantitationSessionManagementUIEnsemble.buttonClickedHeader(QuantitationSessionManagementUIEnsemble.java:69)
at saiman.uiobjnew.PerspectiveActionToolBarHeader.buttonBlicked(PerspectiveActionToolBarHeader.java:23)
at saiman.uiobjnew.PerspectiveToolBarButton.buttonBlicked(PerspectiveToolBarButton.java:37)
at saiman.uiobjnew.PerspectiveToolBarButtonActionListener.actionPerformed(PerspectiveToolBarButtonActionListener.java:18)
... lots of event things

The stack hits my code at: saiman.quantgcms.QuantitationSessionManagementViewPerspectiveUI.saveSession(QuantitationSessionManagementViewPerspectiveUI.java:235)

which is on the line marked below:

FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream out = new ObjectOutputStream(fos);
		
CalibrantContainer calibrantContainer = frame.getCalibrantContainer();
		
out.writeObject(calibrantContainer);  //<<<<< error here
		
out.close();
fos.close();

I'm new to Serialization, and i should have built my class (its quite big) arround it, rather than make the class serializable right at the end. But I didn't plan it particually well...

I know there are Serializable and Nonserializable Objects, my calibrantContainer object implements serializable (or extends JayPanel whch extends JPanel):

public class CalibrantContainer extends JayPanel implements TargettingProcessUpdateListener, IQuantitationDataFileListContainer
{
	transient private static final long serialVersionUID = -52662875082249716L;

now, i know that NotSerializableException occours when i am trying to serialize something tha is Nonserializable, and that Nonserializable objects need to be declaired transient. So as a test (to norrow down this com.sun.java.swing.plaf.windows.XPStyle) i made all fields transient, like this in the JayPanel:

public class JayPanel extends JPanel{

private static final long serialVersionUID = 5592038570698995942L;

transient protected GridBagLayout gbl;
transient protected GridBagConstraints gbc;

transient Border border;
transient TitledBorder enabledTitledBorder;
transient TitledBorder disabledTitledBorder;
transient String title;

public JayPanel(){
super();
initaliseJayPanel("");
}

//other methods
}

edit : just tested and my JayPanel serializes on its own

and I still get it, the stack trace is useless at telling me where this com.sun.java.swing.plaf.windows.XPStyle is, I have not used anything called XPStyle (that i know of) and with all fields transient, how could there possibly be a NotSerializableException?

I would appreciate it if anyone could help me somehow find this "XPStyle" or decifer what the stack trace can tell me. Or any other usefull debugging tips!

Regards

edit: tested JayPanel, it works fine - so there must be something in my class that is not serializable. Even though everything is transient (i left the JayPanel code in, because its what I have done to try and make my other class work)

God this is frustrating!

There must be some way to find out where the hell this XPStyle object is...

If i comment out all 1280 lines of code then the object is fine, however with ALL fields transient the object throws an exception that gives no indication of where the problem lies...

update - commenting out every single method body fixes the problem

now i will re-implement it untill i find out what was wrong...

Result, in a way... The following results in the exception:

transient private JTable compoundList;

public void createButtons()
{
	compoundSetupDatabase = new CompoundSetupDatabase(this);
		
	compoundList = new JTable();            //<< Here
}

If the line marked "here" is included, the error occours when trying to write the object. If it is commented out then i can write it fine.

It appears I cant use JTables, even though the JTable object is transient (and JTable implements Serializable), it still causes this wierd XPStyle error if I do anything with it.

createButtons() is called before the object is Serialized

how can i make an object with a JTable serializable? (i know to overide readObject and call createButtons() etc to make the new JTable to fill out, as this will not be serialized, but how do I exclude it form saving/crashing on attempt to save the JTable?)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.