0

Why do i get a "Stack overflow on call to Ljava/util/WeakHashMap" error when xstream is converting the ShootRecord to xml?

ShootRecord class fields and constructor

public class ShootRecord /* implements Serializable */
{
    private String mShootRecordName = "";
    private String mShootRecordDate = "";
    private int mNumArchersOnTarget;
    private int mScoreSheetTypeIndex;

private Bitmap mScoreSheetBackground = null;

private ArrayList<ScoreSheet> mListOfScoreSheets = new ArrayList<ScoreSheet>();
private int mActiveScoreSheetIndex = 0;

private ScoreSheetsView mScoreSheetsView;

/**
 * Constructs a new ShootRecord object. 
 * @param scoreSheetsView Reference to the score sheet rendering View. 
 * @param name The name string for the shoot record. 
 * @param date The date string for the shoot record. 
 * @param archers The number of archers on the shoot record. 
 * @param sheetType The score sheet type index for the shoot record. 
 */
public ShootRecord(ScoreSheetsView scoreSheetsView, String name, String date, int archers, int sheetType)
{
    mScoreSheetsView = scoreSheetsView;

    mShootRecordName = name;
    mShootRecordDate = date;
    mNumArchersOnTarget = archers;
    mScoreSheetTypeIndex = sheetType;
}

MainActivity class definition:

public class MainActivity extends Activity implements View.OnTouchListener

FileSender class constructor:

public FileSender(Activity activity)
    {
        mMainActivity = (MainActivity) activity;
    }

Method in FileSender:

public boolean postToServletOverWifi(ShootRecord recToSend, Context context){

try{

        /* prepare object as xml */
        XStream xstream = new XStream();

        /* make outputting of xml more concise (optional)*/
        xstream.alias("ShootRecord", ShootRecord.class);

        String xml = xstream.toXML(recToSend);  /* convert object to xml */

        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        wifiManager.startScan();
        List<ScanResult> list = wifiManager.getScanResults();
        for( ScanResult i : list ) {

            /* list network name/ssid */
            i.describeContents();
        }

            /* get user selected wifi network
            /* selectedNetwork = ??? selection from list

            if(selectedNetwork.SSID != null && selectedNetwork.SSID.equals("\"" + networkSSID + "\"")) {
                 wifiManager.disconnect();
                 wifiManager.enableNetwork(selectedNetwork.SSID, true);
                 wifiManager.reconnect();                
                 break;
            }     
            */

        /* Create WifiConfiguration instance: 
            WifiConfiguration conf = new WifiConfiguration();
        conf.SSID = "\"" + networkSSID + "\"";   // string should contain ssid in quotes
                    conf.preSharedKey = "\""+ networkPass +"\"";
                    wifiManager.addNetwork(conf);


        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://" + server + "/Archery");
        post.setHeader("Content-type", "text/xml;charset=utf-8");



some call to post xml?? 
*/

} catch (Exception e){
             System.out.println( e.getMessage() );
             e.printStackTrace();
             return false;

}

} //end method 

Call to method:

public void promptUserToSendShootRecord(ShootRecord recToSend) {

    final ShootRecord shootRecord = recToSend;

    createIntentToSendZippedRecord(shootRecord); //this method works
    postToServletOverWifi(shootRecord, mMainActivity.mContext);
}

catlog

jsky
  • 2,225
  • 5
  • 38
  • 54
  • by putting log calls in my code, ive established that the call converting to xml is the call that is overflowing the stack... – jsky Jul 21 '13 at 08:30

1 Answers1

0

It seems my question is similar to this one Creating an Object in java outside of the init and i may have a recursive call happening here but am unsure where/why

Community
  • 1
  • 1
jsky
  • 2,225
  • 5
  • 38
  • 54