Search code examples
jmeterbeanshell

Beanshell Integer.parseInt() errors


Hey I'm doing some beanshell scripting for a web application in jmeter. I've written quite a few jmeter scripts with beanshell embedded already and for some reason this one keeps giving me errors about my Integer.parseInt() method invocation.

Here's the error:

2014/06/27 10:08:58 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: import java.io.*; import java.util.*; int containerCount = 0; int secondVal = . . . '' : Method Invocation Integer.parseInt 2014/06/27 10:08:58 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:import java.io.; import java.util.; int containerCount = 0; int secondVal = . . . '' : Method Invocation Integer.parseInt

All of my Integer.parseInt() invocations are listed below and they all seem pretty legitimate to me, if anyone's a beanshell expert and could help me identify the error, that'd be awesome, Thanks!

int containerCount = 0;
int secondVal = 0;
int BPNumSelected = 0;  //Branch Plant only is in response page with more than one container, in the site shipment but must be initialized to something here.
boolean mult = false;   //Boolean to see if the site shipment has more than one container

String ScontainerCount= vars.get("availableQty_matchNr");
String SsecondVal = vars.get("secondVal");




    if(ScontainerCount!=null)
        containerCount = Integer.parseInt(ScontainerCount); //refers to the number of containers in that site shipment
    if(SsecondVal!=null)
        secondVal = Integer.parseInt(SsecondVal); //A weird value that is passed in the parameter name after selectedLotID, 


    if(vars.get("BPNumSelected")==null){
        vars.put("BPNumSelected","0");
    }

    if(containerCount>1){
    String SBPNumSelected = vars.get("BPNumSelected");
    BPNumSelected = Integer.parseInt(SBPNumSelected); //gets the branch plant ID if more than one container
    mult = true;
    }

and also...

SlocPackedQtyValue = vars.get("locPackedQtyValue");
SavailQtyNoComma = vars.get("availQtyNoComma");

        if(vars.get("locPackedQtyValue")!=null)
            packedQtyVal = Integer.parseInt(SlocPackedQtyValue);
        if(vars.get("availQtyNoComma")!=null)
            availableRoom = Integer.parseInt(SavailQtyNoComma);

Solution

  • Try to use just packedQtyVal = ${locPackedQtyValue} without Integer.parseInt() method. It works for me in Jmeter 2.11 in BeanShell and BSF processors.