Shrikant Borse
Shrikant Borse

Reputation: 175

How to pass xml file to new object in Jmeter

I am importing a JPOS jar to jmeter.

using the same jar i am creating the ISO massages.

while invoking the "GenericPackager packager = new GenericPackager("basic.xml");" getting an error as "Typed variable declaration : Object constructor"

Can someone help me to create object.

below is the Benshel code.

import java.io.*;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.packager.GenericPackager;


    //public class BuildISOMessage {

    //  public static void main(String[] args) throws IOException, ISOException {
            // Create Packager based on XML that contain DE type
            GenericPackager packager = new GenericPackager("basic.xml");

Upvotes: 1

Views: 766

Answers (2)

Shrikant Borse
Shrikant Borse

Reputation: 175

The issues was because of "genericpackager.dtd" not placed at same location where "basic.xml".

once you placed same its running fine

Upvotes: 1

Dmitri T
Dmitri T

Reputation: 168002

Your code looks fine, the only reason I can think of is JMeter is not being able to locate basic.xml file. Consider the following workarounds:

  • Copy basic.xml file to JMeter's "bin" folder
  • Pass full path to basic.xml file to GenericPackager constructor like:

    GenericPackager packager = new GenericPackager("C:/somefolder/anotherfolder/basic.xml");
    

In general you cat surround your code with try/catch block and print the stacktrace into JMeter log file as follows:

try {
    //your code here
}
catch (Throwable ex) {
    log.error("Something went wrong", ex);
    throw ex;
}

When an error occurs you will be able to see detailed message in jmeter.log file.

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using Beanshell in JMeter tests.

It looks like it isn't a problem to build an ISO message using Beanshell following steps from Jimmy's Blog – ISO 8583 Tutorial – Build and Parse ISO Message using JPOS library post:

JMeter Beanshell JPOS

Upvotes: 1

Related Questions