Salve. Ho un problema nella serializzazione di un oggetto.
La mia classe SimLogonMessage implements Serializable.codice:public char[] ObjToChar(Object obj){ char[] arr = null; if (obj instanceof SimLogonMessage) { SimLogonMessage sim = (SimLogonMessage)obj; ByteArrayOutputStream b = new ByteArrayOutputStream(); ObjectOutputStream oos; try { oos = new ObjectOutputStream(b); oos.writeObject(sim); oos.flush(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } byte[] serializedBytes = b.toByteArray(); arr = new char[serializedBytes.length]; for (int i = 0; i < serializedBytes.length; i++) { arr[i] = (char) serializedBytes[i]; } } return arr; }
Mi dà questa eccezione:
Sto sbattendo la testa non capisco, qual'è il problema???codice:SimDispatcherXML] received message with id: ACGMESSAGETYPE_ACMSENDVCI java.io.NotSerializableException: sim.aiftypes.types.common.AcgLatLon 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.writeObject(Unknown Source) at sim.aiftypes.types.dll.MessageLogon.ObjToChar(MessageLogon.java:147) at sim.aiftypes.types.dll.MessageLogon.<init>(MessageLogon.java:42) at sim.gui.panel.SimDllMsgOutPanel.getAcgDllGetLogonReturn(SimDllMsgOutPanel.java:754) at sim.gui.panel.DllMessageOutButtonActionListener.actionPerformed(DllMessageOutButtonActionListener.java:48) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source)

Rispondi quotando