I'm having problems saving an XML file.

I have a JTree that I am changing to an object, then saving to XML via the XMLEncoder. This was working fine when I was just doing it locally, but now I'm doing it over the network.

I send the JTree as an object over the network to the server. The server then saves it. Here is the code:

Code:
	public void saveFile() {
		try {
			inStream = new ObjectInputStream(cSocket.getInputStream());
			Object tree = fetchObject(inStream);
			System.out.println("recieved >>" + tree);
			String fileName = "example.xml";
			File f = new File(fileName);
			XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
					new FileOutputStream(f)));
			e.flush();
			e.writeObject(tree);
			e.close();
		} catch (IOException io) {
			System.out.println("I/O error");
		}
	}
Code:
	public static Object fetchObject(ObjectInputStream ois) throws IOException {
		Object in = null;
		try {
			in = ois.readObject();
			// Print data
			System.out.println("Incoming packet --> " + in);
		} catch (ClassNotFoundException cnf) {
			System.out.println("unrecognized object type");
		}
		return in;
	}
The server gets the following error:

at java.beans.XMLEncoder.writeExpression(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
The resulting XML file is:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0_06" class="java.beans.XMLDecoder">
Where it should be much longer.

Any ideas what I'm doing wrong?