+ Start a Discussion
mc1392mc1392 

finding exact field causing problem when creating object in salesforce

All,

 

I am trying to pipoint the field that is causing my exception. I am creating a custom object.

The error message is vague.

 

here's the exception:

 

 

AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.io.IOException: java.lang.NullPointerException faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.io.IOException: java.lang.NullPointerException at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:275) at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504) at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:734) at org.apache.axis.encoding.ser.ArraySerializer.serialize(ArraySerializer.java:414) at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504) at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:801) at org.apache.axis.message.RPCParam.serialize(RPCParam.java:208) at org.apache.axis.message.RPCElement.outputImpl(RPCElement.java:433) at org.apache.axis.message.MessageElement.output(MessageElement.java:1208) at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:139) at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478) at org.apache.axis.message.MessageElement.output(MessageElement.java:1208) at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315) at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269) at org.apache.axis.SOAPPart.saveChanges(SOAPPart.java:530) at org.apache.axis.SOAPPart.getContentLength(SOAPPart.java:229) at org.apache.axis.Message.getContentLength(Message.java:510) at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:371) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at com.sforce.soap.partner.SoapBindingStub.create(SoapBindingStub.java:2075) at mybeans.AccountLoader6.createFinancialAccounts(AccountLoader6.java:2611) at mybeans.AccountLoader6.uploadFinancialAccounts(AccountLoader6.java:641) at mybeans.AccountLoader6.main(AccountLoader6.java:179)

 Here's the code:

 

private static List<String> createFinancialAccounts( List<FinancialAccount> account, SoapBindingStub binding, CryptWorker cryptWorker, List<String> contactIDs) throws UnsupportedEncodingException { System.out.println("create " + account.size() + " FinancialAccounts"); System.out.println("Creating FAs"); List<String> FAIDs = new ArrayList<String>(); LinkedList<SObject> updateList = new LinkedList<SObject>(); int counter1 = 0; for (Iterator<FinancialAccount> it = account.iterator(); it.hasNext();) { FinancialAccount fas = it.next(); MessageElement[] contact = null; if (fas.getBirthday() != null) { contact = new MessageElement[31]; contact[30] = new MessageElement(new QName("FABirthday__c"), fas.getBirthday()); } else { contact = new MessageElement[30]; } String decryptedTaxID = cryptWorker.decrypt(fas.getId().getTaxid()); contact[0] = new MessageElement(new QName("AccountOwner__c"), fas .getContactid()); if (fas.getState() != null && fas.getState() != "") { contact[1] = new MessageElement(new QName("FAState__c"), fas .getState()); } else { contact[1] = new MessageElement(new QName("FAState__c"), ""); } if (fas.getZipcode() != null && fas.getZipcode() != "") { contact[2] = new MessageElement(new QName("FAZip__c"), fas .getZipcode()); } else { contact[2] = new MessageElement(new QName("FAZip__c"), ""); } if (fas.getNameline1() != null) { contact[3] = new MessageElement(new QName("NameLine1__c"), fas .getNameline1()); } else { contact[3] = new MessageElement(new QName("NameLine1__c"), ""); } if (fas.getNameline2() != null && fas.getNameline2() != "") { contact[4] = new MessageElement(new QName("NameLine2__c"), fas .getNameline2()); } else { contact[4] = new MessageElement(new QName("NameLine2__c"), ""); } if (fas.getNameline3() != null) { contact[5] = new MessageElement(new QName("NameLine3__c"), fas .getNameline3()); } else { contact[5] = new MessageElement(new QName("NameLine3__c"), ""); } if (fas.getNameline4() != null && fas.getNameline4() != "") { contact[6] = new MessageElement(new QName("NameLine4__c"), fas .getNameline4()); } else { contact[6] = new MessageElement(new QName("NameLine4__c"), ""); } if (fas.getNameline5() != null && fas.getNameline5() != "") { contact[7] = new MessageElement(new QName("NameLine5__c"), fas .getNameline5()); } else { contact[7] = new MessageElement(new QName("NameLine5__c"), ""); } if (fas.getNameline6() != null && fas.getNameline6() != "") { contact[8] = new MessageElement(new QName("NameLine6__c"), fas .getNameline6()); } else { contact[8] = new MessageElement(new QName("NameLine6__c"), ""); } if (fas.getRepid() != null && fas.getRepid() != "") { contact[9] = new MessageElement(new QName("RepID__c"), fas .getRepid()); } else { contact[9] = new MessageElement(new QName("RepID__c"), ""); } if (decryptedTaxID != null && decryptedTaxID != "") { contact[10] = new MessageElement(new QName("TaxID__c"), decryptedTaxID.trim()); } else { contact[10] = new MessageElement(new QName("TaxID__c"), ""); } if (fas.getInterestedparty() != null) { contact[11] = new MessageElement( new QName("InterestedParty__c"), fas .getInterestedparty()); } else { contact[11] = new MessageElement( new QName("InterestedParty__c"), 1); } contact[12] = new MessageElement(new QName("Name"), fas.getId() .getAccountnumber()); contact[13] = new MessageElement(new QName("AccountID__c"), fas .getId().getAccountnumber()); if (fas.getBackoffice() != null) { contact[14] = new MessageElement(new QName("BackOffice__c"), fas.getBackoffice()); } else { contact[14] = new MessageElement(new QName("BackOffice__c"), ""); } if (fas.getCurrentmv() != null) { contact[15] = new MessageElement( new QName("FACurrentMktVal__c"), fas.getCurrentmv()); } else { contact[15] = new MessageElement( new QName("FACurrentMktVal__c"), new BigDecimal("0.00")); } if (fas.getBalancesasof() != null) { contact[16] = new MessageElement(new QName("BalancesAsOf__c"), fas.getBalancesasof()); } else { contact[16] = new MessageElement(new QName("BalancesAsOf__c"), TradeHelper.asOfDate(dateString)); } contact[17] = new MessageElement(new QName("Update_Method__c"), "AUTO"); if (fas.getCity() != null) { contact[18] = new MessageElement(new QName("FACity__c"), fas .getCity()); } else { contact[18] = new MessageElement(new QName("FACity__c"), ""); } if (fas.getBusinessphone() != null) { contact[19] = new MessageElement(new QName("BusinessPhone__c"), fas.getBusinessphone()); } else { contact[19] = new MessageElement(new QName("BusinessPhone__c"), ""); } if (fas.getHomephone() != null) { contact[20] = new MessageElement(new QName("HomePhone__c"), fas .getHomephone()); } else { contact[20] = new MessageElement(new QName("HomePhone__c"), ""); } if (fas.getAccounttype() != null) { contact[21] = new MessageElement(new QName("AccountType__c"), fas.getAccounttype()); } else { contact[21] = new MessageElement(new QName("AccountType__c"), ""); } if (fas.getRetirementaccount() != null) { contact[22] = new MessageElement(new QName( "RetirementAccount__c"), fas.getRetirementaccount()); } else { contact[22] = new MessageElement(new QName( "RetirementAccount__c"), false); } if (fas.getAccountsource() != null) { contact[23] = new MessageElement(new QName("AccountSource__c"), fas.getAccountsource()); } else { contact[23] = new MessageElement(new QName("AccountSource__c"), ""); } contact[24] = new MessageElement( new QName("BalancesUpdateDate__c"), balancesupdatedate); if (fas.getNameaddressasof() != null) { contact[25] = new MessageElement( new QName("NameAddressAsOf__c"), fas .getNameaddressasof()); } else { contact[25] = new MessageElement( new QName("NameAddressAsOf__c"), TradeHelper .asOfDate(dateString)); } if (fas.getCurrentcash() != null) { contact[26] = new MessageElement(new QName("FACurrentCash__c"), fas.getCurrentcash()); } else { contact[26] = new MessageElement(new QName("FACurrentCash__c"), new BigDecimal("0.00")); } if (fas.getHouseholdid() != null) { contact[27] = new MessageElement(new QName("HouseHold__c"), fas .getHouseholdid()); } else { contact[27] = new MessageElement(new QName("HouseHold__c"), null); } if (fas.getMgmtstyle() != null) { contact[28] = new MessageElement(new QName("ProgramName__c"), fas .getMgmtstyle()); } else { contact[28] = new MessageElement(new QName("ProgramName__c"), null); } if (fas.getBackoffice()!= null) { contact[28] = new MessageElement(new QName("Custodian__c"), fas .getBackoffice()); } else { contact[28] = new MessageElement(new QName("Custodian__c"), null); } SObject cons = new SObject(); cons.setType("EAST_FinancialAccount__c"); cons.set_any(contact); updateList.add(cons); counter1++; for (int i = 0; i < contact.length; i++) { System.out.println(contact[i]); } } int part; int offset = 0; int count = updateList.size(); while (count > 0) { part = 0; while (part < UPSERT_BATCH_SIZE && count > 0) { part++; count--; } SObject[] UPDATES = new SObject[part]; for (int x = offset; x < part + offset; x++) { if (x < updateList.size()) { UPDATES[x - offset] = updateList.get(x); } else { break; } } if (UPDATES.length > 0) { // HERE we update all the balances try { SaveResult[] saveResults = binding.create(UPDATES); for (SaveResult result : saveResults) { if (result.isSuccess()) { FAIDs.add(result.getId()); System.out.println("Success!"); } else { System.err .println("Did not create Financial Account: " + result.getErrors(0) .getMessage()); System.err.println(result.getErrors()[0]); FAIDs.add(null); } } // loop through the results, checking for errors for (int j = 0; j < saveResults.length; j++) { if (saveResults[j].isSuccess()) { System.out .println("-------------------------------Result" + saveResults[j] + new Integer(j).toString() + ": A financial account with an id of: " + saveResults[j].getId() + " was created."); } else { System.err .println(": Error creating financial account: " + saveResults[j].getErrors()[0] .getMessage() + "\n"); } } } catch (Exception ex) { ex.printStackTrace(); } } offset += UPSERT_BATCH_SIZE; } System.out.println("FAIDS:" + FAIDs.size()); // return created; return FAIDs; }

 

 

 

 

mc1392mc1392

The problem was the Soap Message array size was incorrect.

 However, why can't I get a message stating that , so I dont have to find the needle in the haystack.

 

SuperfellSuperfell
That's all client side stuff, before it even reaches the server. You should log a bug with the Axis folks.
mc1392mc1392

Sorry,

 

but where do I find the 'Axis people'?

 

 

SuperfellSuperfell
http://ws.apache.org/axis/
Abhinav GuptaAbhinav Gupta

Try creating MessageElement as suggested in alternate solution here. I am very sure it should fix your problem

 

 

http://www.tgerm.com/2010/06/messageelement-out-memory-salesforce.html