// Return the result bytes
byte [] bytes = bos.toByteArray();
// Setup an object input stream.
ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(new ByteArrayInputStream(bytes));
ois.setClassLoader(classLoader);
// Create a new token context and deserialize it from the stream
newObject = ois.readObject();
}
catch (IOException e)
{
ExceptionUtil.printTrace(e);
throw new CloneNotSupportedException("Cannot clone object of type '" + object.getClass().getName() + "'");