我看到了以下错误,因为您可以看到没有提到我的任何类。我有一个multivieweditoreelement的子类。我假设例外是从这里产生的。我应该做些什么来摆脱异常吗?
这是班级。
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
上的persistenceType
更改为来消除异常persistenceType = TopComponent.PERSISTENCE_NEVER
。但是我想使用persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
是否有一个教程,我可以使用数据对象持久性?
由于multivieweditoreelement实现了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;