abstracta / jmeter-java-dsl

Simple JMeter performance tests API
https://abstracta.github.io/jmeter-java-dsl/
Apache License 2.0
477 stars 59 forks source link

jmx2dsl PathNotFoundException using JSONPostProcessor #190

Closed IamKoN closed 1 year ago

IamKoN commented 1 year ago

using jmeter-java-dsl 1.11 java 20.0.1 Jmeter jmx file contructed with JMeter 5.4.1

here is the section from our jmx file:

          <hashTree>
            <JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="JSON Extractor" enabled="true">
              <stringProp name="JSONPostProcessor.referenceNames">auth_token</stringProp>
              <stringProp name="JSONPostProcessor.jsonPathExprs">$.access_token</stringProp>
              <stringProp name="JSONPostProcessor.match_numbers">1</stringProp>
              <stringProp name="JSONPostProcessor.defaultValues">TokenNotFound</stringProp>
            </JSONPostProcessor>
          <hashTree/>

running

java -jar jmdsl.jar jmx2dsl PI_Performance_V6.jmx

strack trace:

java.lang.IllegalArgumentException: Problem loading XML from:'Performance_V6.jmx'.
Cause:
ClassNotFoundException: com.jayway.jsonpath.PathNotFoundException

 Detail:com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : java.lang.NoClassDefFoundError
cause-message       : com/jayway/jsonpath/PathNotFoundException
first-jmeter-class  : org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor.<clinit>(JSONPostProcessor.java:63)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[2]/hashTree[4]/hashTree/JSONPostProcessor
line number         : 451
version             : 1.11
-------------------------------
        at org.apache.jmeter.save.SaveService.readTree(SaveService.java:456)
        at org.apache.jmeter.save.SaveService.loadTree(SaveService.java:429)
        at us.abstracta.jmeter.javadsl.core.engines.JmeterEnvironment.loadTree(JmeterEnvironment.java:115)
        at us.abstracta.jmeter.javadsl.codegeneration.DslCodeGenerator.buildMethodCallFromJmxFile(DslCodeGenerator.java:163)
        at us.abstracta.jmeter.javadsl.codegeneration.DslCodeGenerator.generateCodeFromJmx(DslCodeGenerator.java:157)
        at us.abstracta.jmeter.javadsl.cli.Jmx2DslCommand.call(Jmx2DslCommand.java:49)
        at us.abstracta.jmeter.javadsl.cli.Jmx2DslCommand.call(Jmx2DslCommand.java:15)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at us.abstracta.jmeter.javadsl.cli.Cli.main(Cli.java:34)
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : java.lang.NoClassDefFoundError
cause-message       : com/jayway/jsonpath/PathNotFoundException
first-jmeter-class  : org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor.<clinit>(JSONPostProcessor.java:63)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[2]/hashTree[4]/hashTree/JSONPostProcessor
line number         : 451
version             : 1.11
-------------------------------
        at org.apache.jmeter.save.ScriptWrapperConverter.createConversionException(ScriptWrapperConverter.java:101)
        at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:95)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1421)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1399)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1284)
        at org.apache.jmeter.save.SaveService.readTree(SaveService.java:446)
        ... 15 more
Caused by: java.lang.NoClassDefFoundError: com/jayway/jsonpath/PathNotFoundException
        at org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor.<clinit>(JSONPostProcessor.java:63)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
        at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
        at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
        at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
        at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:547)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:497)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
        at org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:102)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
        at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:93)
        ... 25 more
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.PathNotFoundException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 70 more

tried just using

<stringProp name="JSONPostProcessor.jsonPathExprs">$.</stringProp>

but to no avail.

Thank you

rabelenda commented 1 year ago

Hello, thank you for detailed information and taking time to report this.

We have just released a new version which adds support for JSON Extractor that was part of the problem causing the exception you describe.

I hope this helps.

Regards

rabelenda commented 1 year ago

I am closing this issue since latest release should have fixed this. If you have any related further issues we can re open it.