+ Start a Discussion

Not Serializable: System.XmlStreamWriter

global class BatchJSToWorkdayOfferSync implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts{

	global String xmlStringxmlRes;
	global System.XmlStreamWriter xmlW;
   	global Database.QueryLocator start(Database.BatchableContext BC){
      	xmlW= new System.XmlStreamWriter();
        String query = ' My QUERY';
      return Database.getQueryLocator(query);

global void execute(Database.BatchableContext BC, List<myObject> myObjectList){


global void finish(Database.BatchableContext BC){
		xmlW.writeEndDocument(); //Close XML document
		xmlStringxmlRes = xmlW.getXmlString();
		System.debug('The XML :'+xmlW.getXmlString());

and I am receiving Not Serializable: System.XmlStreamWriter
Vivek DVivek D
Try declaring the variables as Transient
It will work
Need to have a property. Have you tried it? In a Batch?