You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by bu...@apache.org on 2008/12/07 13:14:24 UTC

DO NOT REPLY [Bug 46359] New: BSF JavaScript Preprocessor cannot access sampler variable on first interation

https://issues.apache.org/bugzilla/show_bug.cgi?id=46359

           Summary: BSF JavaScript Preprocessor cannot access sampler
                    variable on first interation
           Product: JMeter
           Version: 2.3.2
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: jmeter-dev@jakarta.apache.org
        ReportedBy: NTmatter@gmail.com


Created an attachment (id=22999)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22999)
Test Case illustrating issue

The BSF JavaScript Preprocessor is unable to access the Sampler variable in the
first iteration, citing the following exception:

org.apache.bsf.BSFException: JavaScript Error: Internal Error:
org.mozilla.javascript.EcmaError: ReferenceError: "sampler" is not defined.

Steps to Reproduce:
1-Create a Thread Group set to run for two or more iterations
2-Add a Sampler to the Thread Group (tested with an HTTP Sampler)
3-Add a BSF PreProcessor to the Sampler
4-Use javascript as the BSF Language
5-Enter a simple script that references the "sampler" variable. Tested with
OUT.println("hello"); OUT.println(sampler);
6-Run

Expected Results:
 - All iterations produce console output "hello\n[sampler information]"

Actual Results:
 - First Iteration, only "hello" is output to console.
 - Log Output: 2008/12/07 12:21:51 WARN  - jmeter.modifiers.BSFPreProcessor:
Problem in BSF script org.apache.bsf.BSFException: JavaScr
ipt Error: Internal Error: org.mozilla.javascript.EcmaError: ReferenceError:
"sampler" is not defined. 
 - Second and further iterations "hello\n[sampler information]"

Affects Versions:
 - Trunk revision 722843 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=722843 )
 - Release 2.3.2


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359





--- Comment #1 from Thomas Johnson <NT...@gmail.com>  2008-12-07 04:52:23 PST ---
In version 2.3.2, this issue affects both the Pre and Post Processors. As of
the current trunk (722032) this only affects the Pre Processor.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359





--- Comment #4 from Sebb <se...@apache.org>  2008-12-08 09:57:35 PST ---
As far as I can tell, the problem is in BSF, in the Javascript engine wrapper.

I raised https://issues.apache.org/jira/browse/BSF-22 for the error.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359


Sebb <se...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #6 from Sebb <se...@apache.org>  2008-12-22 07:54:40 PST ---
Please reopen if the fix does not work


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359





--- Comment #5 from Sebb <se...@apache.org>  2008-12-08 11:04:44 PST ---
I've added a temporary work-round in r724446 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=724446 ) and r724445 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=724445 ).

This is in the current nightlies (from r724447 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=724447 )) if you want to try it out.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359





--- Comment #3 from Thomas Johnson <NT...@gmail.com>  2008-12-08 08:48:03 PST ---
Some research indicates that BSF used to have an issue with registering (but
not declaring) a null bean back in mid-2004 (Ref 1). 

>From the snippet below, a quick run of the test case shows that BSF Jexl
handles the null "prev" object just fine. As BSF Jexl and JS get set up by the
same code, it is most likely that the issue lies in or close to Rhino itself.

-- Test Case output --
BSF Jexl
Context: false
Variables: false
Sampler: false
BSF JS
Context: false
Variables: false

-- References --
(1) Commits fixing BSF issue 20355:
http://markmail.org/message/ymna5ppb4556og4k


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 46359] BSF JavaScript Preprocessor cannot access sampler variable on first interation

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46359





--- Comment #2 from Sebb <se...@apache.org>  2008-12-08 07:13:15 PST ---
Thanks for the report and test case.

This appears to be due to a bug in either BSF or Rhino, not JMeter.

It does not appear to be possible to define a script variable with a null value
to Javascript using BSF. Furthermore, any variables which are defined after the
null value will also be inaccessible.

The null variable in this case is "prev", so a work-round is to ensure that
there is at least one previous sample result.

The JMeter code can be rearanged to define the "prev" variable last, but
obviously that is also only a work-round.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org