2013-05-27 49 views
0

我看到以下錯誤,因爲您可以看到沒有提及任何我的類。我有一個MultiViewEditorElement的子類。我假設這裏有例外。有沒有什麼具體的我應該怎麼做才能夠擺脫異常?TopComponent不可序列化

這是class

INFO [org.netbeans.core.windows.persistence]: TopComponent MultiView-puml#007Ctext#002Ehistory#007C is not serializable. 
java.io.NotSerializableException: org.netbeans.core.windows.RegistryImpl 
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180) 
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) 
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) 
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) 
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) 
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) 
    at org.netbeans.core.multiview.MultiViewPeer.peerWriteExternal(MultiViewPeer.java:523) 
    at org.netbeans.core.multiview.MultiViewCloneableTopComponent.writeExternal(MultiViewCloneableTopComponent.java:213) 
    at org.openide.windows.TopComponent$Replacer.writeObject(TopComponent.java:1787) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:601) 
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) 
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) 
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) 
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) 
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) 
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport.storeSerialData(XMLSettingsSupport.java:274) 
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport.storeToXML10(XMLSettingsSupport.java:115) 
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport$Convertor.write(XMLSettingsSupport.java:1174) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:601) 
    at org.openide.loaders.InstanceDataObject.convertorWriteMethod(InstanceDataObject.java:1617) 
    at org.openide.loaders.InstanceDataObject.storeThroughConvertor(InstanceDataObject.java:1604) 
    at org.openide.loaders.InstanceDataObject.storeSettings(InstanceDataObject.java:358) 
    at org.openide.loaders.InstanceDataObject.access$900(InstanceDataObject.java:92) 
    at org.openide.loaders.InstanceDataObject$Creator.run(InstanceDataObject.java:1565) 
    at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127) 
    at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609) 
    at org.openide.loaders.DataObjectPool.runAtomicActionSimple(DataObjectPool.java:229) 
    at org.openide.loaders.InstanceDataObject$Creator.createInstanceDataObject(InstanceDataObject.java:1579) 
    at org.openide.loaders.InstanceDataObject.create(InstanceDataObject.java:343) 
    at org.openide.loaders.InstanceDataObject.create(InstanceDataObject.java:319) 
[catch] at org.netbeans.core.windows.persistence.PersistenceManager.saveTopComponents(PersistenceManager.java:834) 
    at org.netbeans.core.windows.persistence.PersistenceManager.saveWindowSystem(PersistenceManager.java:1181) 
    at org.netbeans.core.windows.PersistenceHandler.save(PersistenceHandler.java:323) 
    at org.netbeans.core.windows.WindowSystemImpl.save(WindowSystemImpl.java:93) 
    at org.netbeans.core.NbLifeExit.doStopInfra(NbLifeExit.java:147) 
    at org.netbeans.core.NbLifeExit.run(NbLifeExit.java:97) 
    at org.netbeans.core.startup.ModuleSystem$2.run(ModuleSystem.java:343) 
    at org.netbeans.ModuleManager.shutDownAsync(ModuleManager.java:1971) 
    at org.netbeans.core.startup.ModuleSystem.shutDownAsync(ModuleSystem.java:349) 
    at org.netbeans.core.NbLifeExit.doExit(NbLifeExit.java:134) 
    at org.netbeans.core.NbLifeExit.run(NbLifeExit.java:94) 
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721) 
    at java.awt.EventQueue.access$200(EventQueue.java:103) 
    at java.awt.EventQueue$3.run(EventQueue.java:682) 
    at java.awt.EventQueue$3.run(EventQueue.java:680) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:691) 
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 

編輯

好吧,我能夠通過DataObject改變persistenceTypepersistenceType = TopComponent.PERSISTENCE_NEVER消除異常。但我想用persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED有沒有可以用於DataObject持久性的教程?

回答

1

由於MultiviewEditorElement實現Serializable接口,你需要實現以可序列化的方法來使用TopComponent.PERSISTENCE_ONLY_OPENED

private void writeObject(java.io.ObjectOutputStream out) throws IOException 
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException; 
相關問題