Getting error: Can't use the file DataWriter without setting the results directory

Gatling version: 3.11.3
Gatling flavour: Java JDK 11.0.11
Gatling build tool: maven 3.9.7
Gatling maven plugin: 4.9.0

Hello Team,

My apology first, this might be a very silly mistake of mine somewhere, I’m getting below error during standalone execution after packaging.

Exception in thread "main" java.lang.IllegalArgumentException: Can't use the file DataWriter without setting the results directory
        at io.gatling.core.stats.DataWritersStatsEngine$.$anonfun$apply$2(DataWritersStatsEngine.scala:58)

In gatling.conf, I have

 data {
    writers = [console, file]               # The list of DataWriters to which Gatling write simulation data (currently supported : console, file, graphite)

This was working in the previous gatling version (3.9.0). Any idea what I’m missing?

Thanks in advance.

-Pujitha

You mentioned that you’re using maven, but you also mentioned “standalone execution after packaging”.
Are you using a supported workflow, meaning launching with our maven plugin, or do you go with a custom workflow?

You can verify for yourself that our official demo project works out of the box, so I suspect the latter. If so, please stick to the supported workflows. “standalone execution after packaging” is only supported in Gatling Enterprise.

Thanks for your reply Stéphane.

I’m using gatling-maven-plugin-demo for my PoC. The only changes I did there was I included resources, added maven-shade-plugin and set execution goals in gatling-maven-plugin in pom.
So it still follows the workflow I guess.

This is how my updated pom looks on the gatling-maven-plugin-demo-java.

And I run the jar in target using below command after compile.
java -jar gatling-maven-plugin-demo-java-3.11.3.jar -s computerdatabase.ComputerDatabaseSimulation

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>io.gatling.demo</groupId>
  <artifactId>gatling-maven-plugin-demo-java</artifactId>
  <version>3.11.3</version>

  <properties>
    <maven.compiler.release>11</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <gatling.version>${project.version}</gatling.version>
    <gatling-maven-plugin.version>4.9.4</gatling-maven-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
    <maven-jar-plugin.version>3.4.1</maven-jar-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-charts-highcharts</artifactId>
      <version>${gatling.version}</version>
<!--      <scope>test</scope>-->
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src/test/java</sourceDirectory>

    <resources>
      <resource>
        <directory>src/test/resources</directory>
        <includes>
          <include>**/**</include>
        </includes>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${maven-jar-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>io.gatling</groupId>
        <artifactId>gatling-maven-plugin</artifactId>
        <version>${gatling-maven-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <!-- Enterprise Cloud (https://cloud.gatling.io/) configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-cloud -->
          <!-- Enterprise Self-Hosted configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-self-hosted -->
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>io.gatling.app.Gatling</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>
</project>

The only workflows we support are the ones described in our documentation.
Shading is definitely not in there.

As I explained, this is a workflow we support in Gatling Enterprise.