Yep, that worked. Thanks for your help! Paul Kronquist
-----Original Message----- From: sebb [mailto:[EMAIL PROTECTED] Sent: Friday, December 03, 2004 5:01 PM To: JMeter Users List Subject: Re: BeanShell and Calendar On Fri, 3 Dec 2004 14:07:40 -0600, Paul Kronquist <[EMAIL PROTECTED]> wrote: > I updated my version of JMeter to 2.0.2 and I have the same issue. > > My BeanShell script is this: > > ${__BeanShell(java.util.GregorianCalendar calendar = new > java.util.GregorianCalendar(); calendar.add(java.util.Calendar.DATE, > 1); Date date = calendar.getTime(); new > java.text.SimpleDateFormat("MM/dd/yyyy").format(date))} > > If I remove "calendar.add(java.util.Calendar.DATE, 1);" everything is > fine. Yes, that is the part that is causing the problem. See below. > (So, what I am trying to do is generate tomorrow's date, formatted > like MM/dd/yyyy.) > > The log is attached below, but this error shows up whether or not I > include the statement above. Are you sure? See below. > > ----------------------------------------------- > > 2004/12/03 13:57:18 ERROR - jmeter.functions.BeanShell: Error invoking > bsh method eval [...] > Caused by: Parse error at line 1, column 66. Encountered: ( > at bsh.Parser.generateParseException(Unknown Source) This indicates that there is a syntax error in the string that has been passed to be evaluated by BeanShell. Tried the same code in the BeanShell Sampler, and it worked OK ... Turns out that he problem is the comma in the calendar.add parameter list - this is being taken as the end of the BeanShell script, and the rest of the text is then being interpreted as the second parameter to the BeanShell function, i.e. the variable name in which to store the value. If you escape the comma using a backslash, the problem goes away. I guess it would be possible to do some validation on the variable name to check that it is "sensible" - e.g. alphanumeric plus some other characters - and log a warning if special characters are found in the name. The same validation should probably be done the JavaScript function. By the way, 2.0.2 allows you to define a startup script for the BeanShell function (see jmeter.properties). The script could define a parameter-less function that returned the formatted date - this would be much easier to use as a function parameter. S. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

