On 24/07/2009, Noel O'Brien <[email protected]> wrote:
> Hi,
>
>  Does the XPath Extractor have the ability to set up multiple variables just 
> like the regex retractor (XXX_1, XXX_2, XXX_matchNo)?

Yes, see just after the Parameters table in:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#XPath_Extractor

>  I've played around with it some more, I removed saxon jar files I had in the 
> Sun6 jre/lib/ext folder and from JMeter's lib folder.
>
>  Now the java spike runs fime from Jedit console and from the system command 
> line. I also tweaked the java program to make it into beanshell and it runs 
> ok in standalone beanshell from the system command line

What happens if you add all the jars in the JMeter lib/ directory to
the classpath?

>  Now when I run it from JMeter (saxon jars removed from lib folder), the 
> following error is showing up in the log file:
>
>  2009/07/24 12:21:16 INFO - jmeter.util.BeanShellTestElement: Starting 
> /home/nobrien/projects/newbay/main/sng/sng-acceptance-tests/test/jmeter/data/scripts/ExtractOrderedEntries.bsh
>  2009/07/24 12:21:16 DEBUG - jmeter.util.BeanShellTestElement: Parameters:
>  2009/07/24 12:21:16 ERROR - jmeter.util.BeanShellInterpreter: Error invoking 
> bsh method: source Sourced file: 
> /home/nobrien/projects/newbay/main/sng/sng-acceptance-tests/test/jmeter/data/scripts/ExtractOrderedEntries.bsh
>  : Typed variable declaration : Class: XPathFactoryImpl not found in namespace

Probably a clash of XML parsers.

Can you send me ExtractOrderedEntries.bsh privately?

>  2009/07/24 12:21:16 WARN - jmeter.extractor.BeanShellPostProcessor: Problem 
> in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking 
> bsh method: source Sourced file: 
> /home/nobrien/projects/newbay/main/sng/sng-acceptance-tests/test/jmeter/data/scripts/ExtractOrderedEntries.bsh
>  : Typed variable declaration : Class: XPathFactoryImpl not found in namespace
>
>  Looks like it can't find a XPathFactoryImpl class in the classpath. From the 
> standalone beanshell and java app now run from the system command line, the 
> following classes are used to successfully execute the XPaths:
>
>  >>>>>>>>>>>>>>>>>>>>
>
>  nobr...@olympia:~/sandbox/Java/XPath$ beanshell XPathDemo.bsh
>
>  DocumentBuilderFactory: 
> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
>  DocumentBuilder: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl
>  Document: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
>  XPathFactory: com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
>  XPath: com.sun.org.apache.xpath.internal.jaxp.XPathImpl
>  XPathExpression: com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl
>  NodeList: com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList
>
>  updatedNodes: 22
>  displayNameNodes: 22
>  statusNodes: 22
>  snsNodes: 22
>
>  >>>>>>>>>>>>>>>>>>>>
>
>  Looks like when JMeter runs it somehow is not able to find 
> com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl ??
>
>  FWIW, here's the JARS that are in JMETER/lib:
>
>  nobr...@olympia:/usr/local/jmeter/bin$ l ../lib/
>  total 16316
>  -rw-r--r-- 1 nobrien nobrien 72851 2008-06-10 01:26 
> avalon-framework-4.1.4.jar
>  -rw-r--r-- 1 nobrien nobrien 369001 2008-06-10 01:26 batik-awt-util-1.6.jar
>  -rw-r--r-- 1 nobrien nobrien 1178641 2009-02-27 16:38 bcprov-jdk15-130.jar
>  -rw-r--r-- 1 nobrien nobrien 113369 2008-06-10 01:26 bsf-2.4.0.jar
>  -rw-r--r-- 1 nobrien nobrien 8585 2008-06-10 01:31 bshclient.jar
>  -rw-r--r-- 1 nobrien nobrien 32887 2009-02-27 16:38 bsh-commands-2.0b4.jar
>  -rw-r--r-- 1 nobrien nobrien 143992 2009-02-27 16:38 bsh-core-2.0b4.jar
>  -rw-r--r-- 1 nobrien nobrien 46725 2008-06-10 01:26 commons-codec-1.3.jar
>  -rw-r--r-- 1 nobrien nobrien 571259 2008-06-10 01:26 
> commons-collections-3.2.jar
>  -rw-r--r-- 1 nobrien nobrien 305001 2008-06-10 01:26 
> commons-httpclient-3.1.jar
>  -rw-r--r-- 1 nobrien nobrien 109043 2008-06-10 01:26 commons-io-1.4.jar
>  -rw-r--r-- 1 nobrien nobrien 132165 2008-06-10 01:26 commons-jexl-1.1.jar
>  -rw-r--r-- 1 nobrien nobrien 261809 2008-06-10 01:26 commons-lang-2.4.jar
>  -rw-r--r-- 1 nobrien nobrien 60841 2008-06-10 01:26 commons-logging-1.1.1.jar
>  -rw-r--r-- 1 nobrien nobrien 180792 2008-06-10 01:26 commons-net-1.4.1.jar
>  -rw-r--r-- 1 nobrien nobrien 56089 2008-06-10 01:26 
> excalibur-datasource-1.1.1.jar
>  -rw-r--r-- 1 nobrien nobrien 17669 2008-06-10 01:26 
> excalibur-instrument-1.0.jar
>  -rw-r--r-- 1 nobrien nobrien 76725 2008-06-10 01:26 excalibur-logger-1.1.jar
>  -rw-r--r-- 1 nobrien nobrien 44462 2008-06-10 01:26 excalibur-pool-1.2.jar
>  drwxr-xr-x 2 nobrien nobrien 4096 2009-02-27 16:39 ext
>  -rw-r--r-- 1 nobrien nobrien 71952 2008-06-10 01:26 
> htmllexer-2.0-20060923.jar
>  -rw-r--r-- 1 nobrien nobrien 138838 2008-06-10 01:26 
> htmlparser-2.0-20060923.jar
>  -rw-r--r-- 1 nobrien nobrien 65261 2008-06-10 01:26 jakarta-oro-2.0.8.jar
>  -rw-r--r-- 1 nobrien nobrien 1115193 2009-02-27 16:38 javaee.jar
>  -rw-r--r-- 1 nobrien nobrien 142391 2008-06-10 01:26 jCharts-0.7.5.jar
>  -rw-r--r-- 1 nobrien nobrien 153253 2008-06-10 01:26 jdom-1.0.jar
>  -rw-r--r-- 1 nobrien nobrien 98496 2009-02-27 16:38 jndi.jar
>  -rw-r--r-- 1 nobrien nobrien 94535 2008-06-10 01:31 jorphan.jar
>  -rw-r--r-- 1 nobrien nobrien 708951 2008-06-10 01:26 js_rhino1_6R5.jar
>  drwxr-xr-x 2 nobrien nobrien 4096 2009-02-27 12:01 junit
>  -rw-r--r-- 1 nobrien nobrien 120640 2008-06-10 01:26 junit3.8.2.jar
>  -rw-r--r-- 1 nobrien nobrien 86165 2008-06-10 01:26 logkit-1.2.jar
>  -rw-r--r-- 1 nobrien nobrien 703265 2009-04-16 15:29 
> mysql-connector-java-5.1.6-bin.jar
>  -rw-r--r-- 1 nobrien nobrien 1545954 2009-04-17 16:01 ojdbc14.jar
>  -rw-r--r-- 1 nobrien nobrien 278286 2008-06-10 01:26 serializer-2_9_1.jar
>  -rw-r--r-- 1 nobrien nobrien 232498 2008-06-10 01:26 soap.jar
>  -rw-r--r-- 1 nobrien nobrien 1902027 2009-02-27 16:38 swiftmq.jar
>  -rw-r--r-- 1 nobrien nobrien 192042 2008-06-10 01:26 Tidy.jar
>  -rw-r--r-- 1 nobrien nobrien 3176148 2008-06-10 01:26 xalan_2_7_1.jar
>  -rw-r--r-- 1 nobrien nobrien 1229289 2008-06-10 01:26 xercesImpl-2_9_1.jar
>  -rw-r--r-- 1 nobrien nobrien 194354 2008-06-10 01:26 xml-apis-2_9_1.jar
>  -rw-r--r-- 1 nobrien nobrien 24956 2008-06-10 01:26 xpp3_min-1.1.4c.jar
>  -rw-r--r-- 1 nobrien nobrien 411090 2008-06-10 01:26 xstream-1.3.jar
>
>
>  Regards,
>  Noel
>
>  ----- "sebb" <[email protected]> wrote:
>  > On 24/07/2009, Noel O'Brien <[email protected]> wrote:
>  > > Hi,
>  > >
>  > > There are no errors in the jmeter log, only info logged by the script:
>  > >
>  > > 2009/07/24 10:52:23 INFO - jmeter.util.BeanShellTestElement: Starting 
> /home/nobrien/projects/newbay/main/sng/sng-acceptance-tests/test/jmeter/data/scripts/ExtractOrderedEntries.bsh
>  > > 2009/07/24 10:52:23 DEBUG - jmeter.util.BeanShellTestElement: Parameters:
>  > > 2009/07/24 10:52:24 INFO - jmeter.util.BeanShellTestElement: Finished 
> /home/nobrien/projects/newbay/main/sng/sng-acceptance-tests/test/jmeter/data/scripts/ExtractOrderedEntries.bsh
>  (341ms)
>  > >
>  > > However I was playing around and think I may have a lead. I developed 
> the spike script in JEdit and used it's built-in console for running it (this 
> is where everything worked). I discovered though that JEdit seems to be using 
> a different version of Java:
>  > >
>  > > In JEdit Console:
>  > >
>  > > /home/nobrien/sandbox/Java/XPath> java -version
>  > > java version "1.6.0_0"
>  > > OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu10)
>  > > OpenJDK Server VM (build 14.0-b08, mixed mode)
>  > > Process java exited with code 0
>  > >
>  > > In system console:
>  > >
>  > > nobr...@olympia:~/sandbox/Java/XPath$ java -version
>  > > java version "1.6.0_12"
>  > > Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
>  > > Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)
>  > >
>  > > Strangely, the XPath expressions successfully match nodes when the 
> program is run from the IcedTea6 JVM but match nothing when run from the Sun 
> 6 JVM. JMeter is run using the Sun 6 JVM which would explain why the 
> beanshell in my JMeter plan is nbot matching anything either.
>  > >
>  > > I'm not really sure where to go from here: is it a classpath issue or 
> perhaps a bug in the Sun6 JDK? Does anyone have any suggestions on what to 
> try?
>  >
>  > Does XPath Extractor work OK if used to extract one set of nodes (add
>  > a Debug Sampler to show the variables it sets up)?
>  > If so, you could use 4 of them and then process the variables using 
> BeanShell.
>  >
>  > Or you could extract the code and use it in BeanShell.
>  >
>  > Note that you can also run BeanShell in stand-alone mode for testing.
>  >
>  > > Regards,
>  > > Noel
>  > >
>  > >
>  > > ----- "sebb" <[email protected]> wrote:
>  > > > Check jmeter log file for errors from BeanShell.
>  > > >
>  > > > Are you seeing the final log message from the BeanShell script?
>  > > >
>  > > > On 22/07/2009, Noel O'Brien <[email protected]> wrote:
>  > > > > Hi,
>  > > > >
>  > > > > I have to extract an correlate many values from an XML feed. I then 
> need to sort the entries, store them, and compare them against subsequent 
> feeds.
>  > > > >
>  > > > > Given the complexity of the task, I decided to do it with a 
> Beanshell Post-Processor. I first spiked the code in Java and everything 
> worked. However when I moved it into JMeter/Beanshell, the evaluation of the 
> XPath expressions always returns 0 nodes. Making the Document namespace-aware 
> makes no difference. The document parses fine, and printing out "new 
> String(data, "UTF-8")" displays the correct data returned by the sampler.
>  > > > >
>  > > > > Can anyone think of any reasons why this could be happening?
>  > > > >
>  > > > > Here's the code:
>  > > > >
>  > > > > >>>>>>>>>>>>>>>>>>>>
>  > > > >
>  > > > > import org.w3c.dom.*;
>  > > > > import javax.xml.xpath.*;
>  > > > > import javax.xml.parsers.*;
>  > > > > import java.io.*;
>  > > > > import java.nio.*;
>  > > > > import java.nio.channels.*;
>  > > > > import org.xml.sax.*;
>  > > > >
>  > > > >
>  > > > > log.info("Starting "+getSourceFileInfo());
>  > > > > log.debug("Parameters: " + Parameters);
>  > > > > startTime = System.currentTimeMillis();
>  > > > >
>  > > > > params = Parameters.split("\\|");
>  > > > >
>  > > > > sns = params[0];
>  > > > >
>  > > > > // Method for retrieving Node text value
>  > > > > public static String getNodeValue(Node node)
>  > > > > {
>  > > > > if(!node.hasChildNodes()) return "";
>  > > > > else return node.getFirstChild().getNodeValue();
>  > > > > }
>  > > > >
>  > > > > // Build XML document from the response
>  > > > > DocumentBuilderFactory domFactory = 
> DocumentBuilderFactory.newInstance();
>  > > > > domFactory.setNamespaceAware(false);
>  > > > > DocumentBuilder builder = domFactory.newDocumentBuilder();
>  > > > > InputSource inStream = new InputSource();
>  > > > > inStream.setCharacterStream(new StringReader(new String(data, 
> "UTF-8")));
>  > > > > Document doc = builder.parse(inStream);
>  > > > > XPath xpath = XPathFactory.newInstance().newXPath();
>  > > > >
>  > > > >
>  > > > > // Create XPath Expressions
>  > > > > XPathExpression updatedExpr = xpath.compile("/feed/entry/updated");
>  > > > > XPathExpression displayNameExpr = 
> xpath.compile("/feed/entry/author/name");
>  > > > > XPathExpression statusExpr = xpath.compile("/feed/entry/summary");
>  > > > > XPathExpression snsExpr = 
> xpath.compile("/feed/entry/source/author/name");
>  > > > >
>  > > > > // Evaluate XPath Expressions
>  > > > > NodeList updatedNodes = (NodeList)updatedExpr.evaluate(doc, 
> XPathConstants.NODESET);
>  > > > > NodeList displayNameNodes = (NodeList)displayNameExpr.evaluate(doc, 
> XPathConstants.NODESET);
>  > > > > NodeList statusNodes = (NodeList)statusExpr.evaluate(doc, 
> XPathConstants.NODESET);
>  > > > > NodeList snsNodes = (NodeList)snsExpr.evaluate(doc, 
> XPathConstants.NODESET);
>  > > > >
>  > > > > System.out.println("updatedNodes: "+updatedNodes.getLength());
>  > > > > System.out.println("displayNameNodes: 
> "+displayNameNodes.getLength());
>  > > > > System.out.println("statusNodes: "+statusNodes.getLength());
>  > > > > System.out.println("snsNodes: "+snsNodes.getLength());
>  > > > >
>  > > > > // Create data types
>  > > > > /* HashSet<List> set = new HashSet<List>();
>  > > > > TreeMap<Date, HashSet<List>> tree = new TreeMap<Date, 
> HashSet<List>>();*/
>  > > > >
>  > > > > // Put values in data structure
>  > > > > for(int i =0; i < updatedNodes.getLength(); i++)
>  > > > > {
>  > > > > String u = getNodeValue(updatedNodes.item(i));
>  > > > > String d = getNodeValue(displayNameNodes.item(i));
>  > > > > String s1 = getNodeValue(statusNodes.item(i));
>  > > > > String s2 = getNodeValue(snsNodes.item(i));
>  > > > >
>  > > > > // do more stuff
>  > > > > }
>  > > > >
>  > > > >
>  > > > > // Store tree in Object variable
>  > > > > //vars.putObject("individual.friends.statuses.tree", tree);
>  > > > >
>  > > > > finishTime = System.currentTimeMillis();
>  > > > > log.info("Finished "+getSourceFileInfo()+" (" + 
> (finishTime-startTime) + "ms)");
>  > > > >
>  > > > > <<<<<<<<<<<<<<<<<<<<
>  > > > >
>  > > > > JMeter: 2.3.2
>  > > > > Java 1.6.0_12
>  > > > > OS: Linux
>  > > > >
>  > > > > Regards,
>  > > > >
>  > > > > Noel
>  > > > >
>  > > >
>  > >
>  > > > ---------------------------------------------------------------------
>  > > > 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]
>  >
>  >

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to