NoSuchFieldError: DEFAULT_CONFIG_CLASS on Citrus Simulator WS project

100 Views Asked by At

I'm getting this exception when running a fresh generated project using the Maven archetype org.citrusframework.archetypes:citrus-simulator-archetype-ws (Archetype for Citrus SOAP simulator).

I tried whit both 2.1.1 and 2.1.0 versions with the same result:

2022-07-07 10:19:40.718 WARN 3113 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.consol.citrus.config.CitrusSpringConfig]; nested exception is java.lang.NoSuchFieldError: DEFAULT_CONFIG_CLASS

2022-07-07 10:19:40.734 INFO 3113 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2022-07-07 10:19:40.829 ERROR 3113 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.consol.citrus.config.CitrusSpringConfig]; nested exception is java.lang.NoSuchFieldError: DEFAULT_CONFIG_CLASS at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:610) ~[spring-context-5.3.9.jar:5.3.9] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:311) ~[spring-context-5.3.9.jar:5.3.9] at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.9.jar:5.3.9]

I tried to find mixed versions of the spring jars in the dependencies tree with no success. This is the generated pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.example.simulator</groupId>
  <artifactId>ws-simulator</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>Citrus SOAP Simulator</name>
  <packaging>war</packaging>

  <properties>
    <java.version>11</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <citrus.version>3.1.0</citrus.version>
    <citrus.simulator.version>2.1.1</citrus.simulator.version>
    <spring.boot.version>2.5.4</spring.boot.version>
    <testng.version>7.3.0</testng.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Citrus Simulator -->
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-simulator-starter</artifactId>
      <version>${citrus.simulator.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-simulator-ui</artifactId>
      <version>${citrus.simulator.version}</version>
    </dependency>

    <!-- Citrus -->
    <dependency>
      <groupId>com.consol.citrus</groupId>
      <artifactId>citrus-ws</artifactId>
      <version>${citrus.version}</version>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <encoding>${project.build.sourceEncoding}</encoding>
          <source>${java.version}</source>
          <target>${java.version}</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.22.2</version>
        <configuration>
          <failIfNoTests>false</failIfNoTests>
        </configuration>
        <executions>
          <execution>
            <id>integration-tests</id>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring.boot.version}</version>
          <executions>
              <execution>
                  <goals>
                      <goal>repackage</goal>
                  </goals>
                  <configuration>
                      <classifier>executable</classifier>
                  </configuration>
              </execution>
          <execution>
            <id>pre-integration-test</id>
            <goals>
              <goal>start</goal>
            </goals>
            <configuration>
              <fork>true</fork>
            </configuration>
          </execution>
          <execution>
            <id>post-integration-test</id>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

I tried using java 17 at first and switched to java 11 which is the target version in the pom, but nothing changed.

Any ideas where may be the conflict?

1

There are 1 best solutions below

1
MartinL On

It seems like you need to upgrade the citrus dependencies. (Upgrade Citurs Version to 3.2.1)

See as reference https://github.com/Malyky/citrusSoapSimulator