Advertisement

05.12.2008 at 06:19AM PDT, ID: 23394395
[x]
Attachment Details

Listiterator cannot be serialized

Asked by ikjop in Java Programming Language, J2EE

Tags: Java

I recieve the following error message

java.io.NotSerializableException: java.util.AbstractList$ListItr
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
        at worldofpokerclient.ClientAppl.sendObject(ClientAppl.java:49)
        at worldofpokerclient.frmMain.btnCreateTableMouseReleased(frmMain.java:282)
        at worldofpokerclient.frmMain.access$200(frmMain.java:25)
        at worldofpokerclient.frmMain$4.mouseReleased(frmMain.java:88)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
java.io.EOFException
        at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2554)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at worldofpokerclient.ClientAppl.run(ClientAppl.java:101)
BUILD SUCCESSFUL (total time: 9 minutes 55 seconds)

I need to send the class bellow over the network (sendobject), but it won't let me serialize the iterator. How do i resolve this ?
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
package data;
 
 
 
/**
 * THIS IS THE CLASS THAT SPAWNS THE ERROR WHEN I TRY TO SEND IT OVER THE NETWORK.
 * @author unknown
 */
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ListIterator;
 
public class CardDeck implements Serializable {
   private ArrayList<Card> lstDeck = new ArrayList<Card>();
   private ListIterator<Card> itDeck;
    
    CardDeck(){
        initCardDeck();
    }
 
    public ArrayList<Card> getDeck() {
        return lstDeck;
    }
    
    private void initCardDeck(){
        
        lstDeck.add(new Card("hearts",1,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",2,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",3,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",4,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",5,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",6,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",7,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",8,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",9,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",10,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",11,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",12,Card.cardColor.RED));
        lstDeck.add(new Card("hearts",13,Card.cardColor.RED));
      
        lstDeck.add(new Card("diamonds",1,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",2,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",3,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",4,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",5,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",6,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",7,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",8,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",9,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",10,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",11,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",12,Card.cardColor.RED));
        lstDeck.add(new Card("diamonds",13,Card.cardColor.RED));
       
        lstDeck.add(new Card("spades",1,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",2,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",3,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",4,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",5,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",6,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",7,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",8,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",9,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",10,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",11,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",12,Card.cardColor.BLACK));
        lstDeck.add(new Card("spades",13,Card.cardColor.BLACK));
        
         
        lstDeck.add(new Card("clubs",1,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",2,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",3,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",4,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",5,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",6,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",7,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",8,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",9,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",10,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",11,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",12,Card.cardColor.BLACK));
        lstDeck.add(new Card("clubs",13,Card.cardColor.BLACK));             
        
        itDeck = lstDeck.listIterator();
    }
    
    public void shuffleDeck(){
        Collections.shuffle(lstDeck);   
    }
    
    public void removeCard(Card cCardTaken){
       lstDeck.remove(cCardTaken);
    }
    
    public void newDeck(){
        lstDeck.clear();
        initCardDeck();
        shuffleDeck();
    }
    
    public Card getNextCard(){
       return itDeck.next(); 
    }
    public Card getPreviousCard(){
        return itDeck.previous();
    }
    
    public void cutDeck(int iCutPosition){
        Collections.rotate(lstDeck, iCutPosition);
    }
    
}
[+][-]05.12.2008 at 06:28AM PDT, ID: 21546769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 06:29AM PDT, ID: 21546776

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 06:50AM PDT, ID: 21546951

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 06:56AM PDT, ID: 21546998

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Programming Language, J2EE
Tags: Java
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.12.2008 at 06:59AM PDT, ID: 21547015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 07:31AM PDT, ID: 21547299

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628