TopComponent不可序列化

时间:2013-05-27 01:31:49

标签: netbeans netbeans-platform

我看到以下错误,因为您可以看到没有提及我的任何课程。我有一个MultiViewEditorElement的子类。我从这里假设异常弹簧。能够摆脱异常,我应该做些什么吗?

这是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)

修改

好的,我可以通过将persistenceType更改为DataObject来消除此异常 persistenceType = TopComponent.PERSISTENCE_NEVER。但我想使用persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED是否有可用于DataObject持久性的教程?

1 个答案:

答案 0 :(得分:1)

由于MultiviewEditorElement实现了Serializable接口,您需要实现Serializable方法才能使用TopComponent.PERSISTENCE_ONLY_OPENED

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