abstracta/jmeter-java-dsl

com.thoughtworks.xstream.security.ForbiddenClassException: org.apache.jmeter.save.ScriptWrapper

ihsaddamhussain opened this issue · 1 comments

I am trying to run existing Jmx file using DSL, I have added jmeter-plugins-manager, jmeter-plugins-cmn-jmeter and jmeter-plugins-casutg in my dependencies, its very basic script with one Get call. I use an example given in the doc

@Test
  public void testPerformance() throws IOException {
    TestPlanStats stats = DslTestPlan.fromJmx("test-plan.jmx").run();
    assertThat(stats.overall().sampleTimePercentile99()).isLessThan(Duration.ofSeconds(5));
  }

But I always get the below error

com.thoughtworks.xstream.security.ForbiddenClassException: org.apache.jmeter.save.ScriptWrapper
        at com.thoughtworks.xstream.security.NoTypePermission.allows(NoTypePermission.java:26)

I tried the below

System.setProperty("xstream.security.noRestrictions", "true");

and

XStream xStream = new XStream();
        xStream.allowTypesByWildcard(new String[]{
                "org.apache.jmeter.**",
                "java.util.**",
                "com.thoughtworks.xstream.**"
        });

but doesn't work anyway to resolve this ? or get existing xstream object so that i can simply allow all. Looks like Creating new instance just doesnt work or may be its completely different.

It was due to one of the internal dependency was using old ApacheJmeter_core component, I overridden to use the latest version and it worked. Phew!