Reading a external XML file using __XPath(${__P(fileName)} - jmeter

I have a situation where in I am trying to read a node value of an external XML. I am using BeanShell sampler to read the fileName (passed via command line) and using setProperty method setting the value of the parsed node:
${__setProperty(variable_name,${__XPath(${__P(fileName)},/Allocations/item/#name)})}
Though the above method retrieves the value of the node I intended to receive, there is a error thrown:
2013/03/19 19:32:59 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` D:\myProject\Jmeter Tests\allocate.xml ;'' Token Parsing Error: Lexical error at line 2, column 3. Encountered: "\" (92), after : ""
My xml file looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Allocations>
<item name="CAR" />
</Allocations>
Kindly advice if I am doing some error while reading.

Very strange because looks you are doing everything correct.
I've reproduced your scenario step-by-step but works fine for me.
Try to use e.g. Debug Sampler / Debug PostProcessor to monitor your jmeter properties and ensure that fileName normally set from command-line and doesn't contain any extra symbols.

Related

Jmeter "Load environment settings" gives Responsecode 500

Got a JMeter-4.0-project that runs fine on colleagues' laptops, but not on mine. When I run the project, it halts in the Setup phase,
while trying to open the file load_environment_settings.bsh with this message:
Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: source Sourced file: C:\myprograms\apache-jmeter-4.0\bin\CBSPerfProj\trunk\moas..\includes\load_environment_settings.bsh : Typed variable declaration : Object constructor
The file load_environment_settings.bsh does exist and I do have full rights to that file. The entire structure, directory, and files is identical to my colleagues' structure.
Any ideas what can be wrong?

How do I resolve oracle jdbc proxy class error in Evosuite generated tests?

I've written a JDBC driver and I'm trying to use Evosuite to generate the tests for it.
I'm using the following command line:
mvn -Dcores=5 -DmemoryInMB=5000 -Dmock_if_no_generator=false -DextraArgs=' -Dmock_if_no_generator=false -Dskip_covered=true Duse_separate_classloader=false -Dmax_recursion=50 -Dlocal_search_restore_coverage=true -Duse_existing_coverage=true -Dsandbox=false -Dsort_calls=true 'evosuite:generate
The code that is generated is below:
oracle.1jdbc.1replay.1driver.1NonTxnReplayableBase.2java.1sql.1DatabaseMetaData...Proxy oracle_1jdbc_1replay_1driver_1NonTxnReplayableBase_2java_1sql_1DatabaseMetaData___Proxy0 = new oracle.1jdbc.1replay.1driver.1NonTxnReplayableBase.2java.1sql.1DatabaseMetaData...Proxy((DatabaseMetaData) null, "k-{`1N&KKC", proxyFactory0, hashtable0);
and I'm getting the following error on the first line:
:[4618,7] not a statement
:[4618,13] ';' expected
(getting this error three times on the same line)
I was hoping to turn off the mocking but it didn't work it seems.
I'll try to see if I can provide more details later, but any initial thoughts from anyone?
Thanks!

How to add threadName to Jmeter HTML report (error section)

I am facing an issue when I try to analyze Jmeter HTML report.
I use this command to run and create HTML report
jmeter -n -t C:\JMETER_RTB_REQUEST\Framework\Test_Fragment\Test_Fragment_15_02_2018_vol2.jmx -l C:\Users\bs\Desktop\Jmeter_reports\results_geo.csv -e -o C:\Users\bs\Desktop\Jmeter_reports\HTML
The problem is that when I am opening the Html file, under error section it not mention on which test (thread group) it failed, so I can not understand what test failed. In the CSV exists thread name column, but not in the HTML error section. Is their any solution?
[][Thread groups from test plan]
[][CSV report thread Name exists(HTML1 is thread name)]
[[HTML report not mentioned thread Name]]
Since JMeter 4.0, you can customize assertion message:
So you would put custom message assertion including Thread Name calling __threadNum function.

AdminTask.listTCPEndPoints('abc(abc)') throws exception: ADMF0007E: target object is required

I'm working on deploying application to WebSphere 7 using python script and the script is throwing exception at this line:-
AdminTask.listTCPEndPoints('abc(abc)')
If I run the above command before I run the python script, it works fine. It gives me an error ADMF0003E: Invalid parameter value. But the same command fails in the python script with this error:
wsadmin>AdminTask.listTCPEndPoints('abc(abc)')
WASX7015E: Exception running command: "AdminTask.listTCPEndPoints('abc(abc)')"; exception information: com.ibm.websphere.management.cmdframework.CommandValidationException: ADMF0007E: target object is required.
I can guess that there something in the python script that is causing this issue, but I don't understand why is the AdminTask.listTCPEndPoints command is not able to see the parameter being passed. I'm new to WebSphere, I have only used it in past but never configured it. Any help/insight would be highly appreciated.
Thanks!
Added stack trace of interactive mode option
wsadmin>print AdminTask.listTCPEndPoints('-interactive')
List NamedEndPoints that can be used by a TCPInboundChannel
Lists all NamedEndPoints that can be associated with a TCPInboundChannel
*TCPInboundChannel: abc(abc)
excludeDistinguished (excludeDistinguished): 0
WASX7435W: Value 0 is converted to a boolean value of false.
unusedOnly (unusedOnly): 0
WASX7435W: Value 0 is converted to a boolean value of false.
List NamedEndPoints that can be used by a TCPInboundChannel
F (Finish)
C (Cancel)
Select [F, C]: [F] F
WASX7278I: Generated command line: AdminTask.listTCPEndPoints('[-excludeDistinguished false -unusedOnly false]')
WASX7015E: Exception running command: "AdminTask.listTCPEndPoints('-interactive')"; exception information:
com.ibm.websphere.management.cmdframework.CommandValidationException: ADMF0007E: target object is required.
Follow this link. It appears that you have not specified the target object that's why that error is coming.
I suggest use the following command as a starter
print AdminTask.listTCPEndPoints('-interactive')
Note: Instead of copying and pasting the command, type it on the command line. sometimes command editor does not take the command after pasting it directly.
Okay, I was able to fix the error. I was getting that error because as part of the application deployment script, I was copying few of my application jars to WebSphere's java/jre/lib/ext directory so that those are available in classpath. In one of those jar, I had bundled an IBM class (Base64Coder.class) which was required by a class in my jar and it was corrupting the WebSphere AdminTask utility. When I removed that Base64Coder.class from my jar, python script worked fine. I believe, the reason it corrupted WebSphere was that there was a duplication of the same class in the JVM as the class comes with IBM WebSphere installation and was present in AppServer/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar

Subreport Data Source Expression for XML document

I'm trying to get a subreport working for a report using an XML document as a data source.
When I'm sorting main report data, subreport won't have to requery the XML document. Its expecting a JRSortableDataSource, not a JRXmlDataSource.
What am I doing wrong?
I used following datasource expression:
$P{REPORT_DATA_SOURCE}).subDataSource("/person/phone")
The stack trace:
Error filling print... Error evaluating expression : Source text : $P{REPORT_DATA_SOURCE}.subDataSource("/person/phone")
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $P{REPORT_DATA_SOURCE}.subDataSource("/person/phone")
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:966)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:384)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:286)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:459)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:126)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:464)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:300)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:757)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:1003)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: groovy.lang.MissingMethodException:
No signature of method: net.sf.jasperreports.engine.fill.SortedDataSource.subDataSource()
is applicable for argument types: (java.lang.String) values: [/person/phone]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at TestParam_1362739351228_895383.evaluate(calculator_TestParam_1362739351228_895383:223)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190)
Your datasource expression $P{REPORT_DATA_SOURCE}).subDataSource("/B/C")
Has a syntax error
You missed unmatched character at first (
Then
If its expecting a JRSortableDataSource
Use this expression
((net.sf.jasperreports.engine.data.JRSortableDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("DefineThat")
If its expecting a JRXmlDataSource
Use this expression
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("DefineThat")
$P{REPORT_DATA_SOURCE}).subDataSource("Xpath")
when somebody uses the above expression to connect to create sub report in Jasper using XML Datasource we need to set the Report Language as groovy instead of Java .I think subdatasource is not a method defined in Java but in groovy .I'm trying to find a method which is equivalent to above in Java
Had the same issue, found this solution at the jaspersoft-community:
Capturing the original data source in a parameter:
<parameter name="MyDataSource" class="net.sf.jasperreports.engine.JRDataSource" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></defaultValueExpression>
</parameter>
same in iReport-GUI:
create new paramater at the main report
Name: "MyDataSource"
Parameter Class: "net.sf.jasperreports.engine.JRDataSource"
Use as a prompt: No
Default value Expression: "$P{REPORT_DATA_SOURCE}"
Now using the MyDataSource Parameter at the subreport-datasource:
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{MyDataSource}).dataSource("/Subreport/path")]]></dataSourceExpression>

Resources