[229826] NPE during paste when server deleted
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
index f5da0fa..9427589 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -1925,6 +1925,14 @@
 		resolve();
 	}
 
+	public void serialize(IMemento memento) {
+		save(memento);
+	}
+
+	public void deserialize(IMemento memento) {
+		load(memento);
+	}
+
 	protected void resolve() {
 		IServerType oldServerType = serverType;
 		String serverTypeId = getAttribute("server-type-id", (String)null);
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
index ca1aede..0fdad67 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
@@ -281,8 +281,10 @@
 	
 	/**
 	 * Save this Memento to a Writer.
+	 * 
+	 * @throws IOException if there is a problem saving
 	 */
-	protected void save(OutputStream os) throws IOException {
+	public void save(OutputStream os) throws IOException {
 		Result result = new StreamResult(os);
 		Source source = new DOMSource(factory);
 		try {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java
index 77dd773..1f43dc0 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java
@@ -12,14 +12,15 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.TransferData;
 import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.IMemento;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.XMLMemento;
 /*
  * The element serialization format is:
  *  (int) number of servers
@@ -72,17 +73,18 @@
 		IServer[] servers = (IServer[]) data;
 		try {
 			ByteArrayOutputStream out = new ByteArrayOutputStream();
-			DataOutputStream dataOut = new DataOutputStream(out);
-
-			// write the number of elements
-			dataOut.writeInt(servers.length);
-
+			
+			XMLMemento memento = XMLMemento.createWriteRoot("servers");
+			
 			// write each element
-			for (int i= 0; i < servers.length; i++)
-				dataOut.writeUTF(servers[i].getId());
-
+			for (int i = 0; i < servers.length; i++) {
+				IMemento child = memento.createChild("server");
+				((Server)servers[i]).serialize(child);
+			}
+			
+			memento.save(out);
+			
 			// cleanup
-			dataOut.close();
 			out.close();
 			byte[] bytes = out.toByteArray();
 			super.javaToNative(bytes, transferData);
@@ -98,17 +100,22 @@
 		byte[] bytes = (byte[]) super.nativeToJava(transferData);
 		if (bytes == null)
 			return null;
-		DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
+		ByteArrayInputStream in = new ByteArrayInputStream(bytes);
 		try {
-			int count = in.readInt();
+			IMemento memento = XMLMemento.loadMemento(in);
+			IMemento[] children = memento.getChildren("server");
+			
+			int count = children.length;
 			IServer[] results = new IServer[count];
 			for (int i = 0; i < count; i++) {
-				String id = in.readUTF();
-				results[i] = ServerCore.findServer(id);
+				Server server = new Server(null);
+				server.deserialize(children[i]);
+				results[i] = server;
 			}
 			return results;
-		} catch (IOException e) {
-			return null;
+		} catch (Exception e) {
+			DND.error(DND.ERROR_INVALID_DATA);
 		}
+		return null;
 	}
 }
\ No newline at end of file