Can't get Cucumber based tests to work

I have tried to create a very simple Cucumber based test in Katalon Studio 7.9.0, but I’m getting an exception that I don’t know how to resolve. Can anyone help please? Here’s the stack trace…

=============== ROOT CAUSE =====================
Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

05-05-2021 08:13:36 AM Verification

Elapsed time: 0.684s

Verification FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Keyword runFeatureFile was failed (Root cause: cucumber.runtime.CucumberException: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature
at cucumber.runtime.formatter.PluginFactory.newInstance(PluginFactory.java:110)
at cucumber.runtime.formatter.PluginFactory.instantiate(PluginFactory.java:91)
at cucumber.runtime.formatter.PluginFactory.create(PluginFactory.java:76)
at cucumber.runtime.RuntimeOptions.getPlugins(RuntimeOptions.java:317)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:306)
at cucumber.runtime.Runtime.run(Runtime.java:97)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main$run.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy:106)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:73)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:246)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile.call(Unknown Source)
at WSVerification1620224016642.run(WSVerification1620224016642:2)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:178)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:172)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:155)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:147)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:129)
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)
at TempTempCase1620224013456.run(TempTempCase1620224013456.groovy:25)
Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature
at org.apache.xerces.jaxp.DocumentBuilderImpl.newDocument(Unknown Source)
at cucumber.runtime.formatter.JUnitFormatter.(JUnitFormatter.java:88)
at cucumber.runtime.formatter.PluginFactory.newInstance(PluginFactory.java:104)
… 26 more
)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:70)
at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:73)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:246)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile.call(Unknown Source)
at WSVerification1620224016642.run(WSVerification1620224016642:2)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:178)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:172)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:155)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:147)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:129)
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)
at TempTempCase1620224013456.run(TempTempCase1620224013456.groovy:25)
Caused by: cucumber.runtime.CucumberException: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature
at cucumber.runtime.formatter.PluginFactory.newInstance(PluginFactory.java:110)
at cucumber.runtime.formatter.PluginFactory.instantiate(PluginFactory.java:91)
at cucumber.runtime.formatter.PluginFactory.create(PluginFactory.java:76)
at cucumber.runtime.RuntimeOptions.getPlugins(RuntimeOptions.java:317)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:306)
at cucumber.runtime.Runtime.run(Runtime.java:97)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main$run.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy:106)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
… 16 more
Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature
at org.apache.xerces.jaxp.DocumentBuilderImpl.newDocument(Unknown Source)
at cucumber.runtime.formatter.JUnitFormatter.(JUnitFormatter.java:88)
at cucumber.runtime.formatter.PluginFactory.newInstance(PluginFactory.java:104)
… 26 more

Similar issue was there:

Thanks so much! This pointed me in the right direction, I found that if I removed my common testing library jar file from the drivers folder, my cucumber tests would run. However, I don’t see any mention of “xerces” or “tika” in my common library, so I will have to do a lot of trial and error to find where the conflict is. If at all possible (and I know technically it now goes beyond the scope of Katalon), does anything in my common library jar jump out at you as the probably conflict here?

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
	<repository>
		<id>central</id>
		<url>https://repo.maven.apache.org/maven2</url>
	</repository>
</repositories>

<build>
	<sourceDirectory>src/main/java</sourceDirectory>

	<resources>
		<resource>
			<directory>src/main/java</directory>
			<includes>
				<include>**/*.java</include>
				<include>**/*.doc</include>
			</includes>
		</resource>
	</resources>

	<plugins>
		<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        		
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-javadoc-plugin</artifactId>
			<version>2.8.1</version>
			<configuration>
   				<source>8</source>
				<additionalparam>-Xdoclint:none</additionalparam>
				<failOnError>false</failOnError>
				<tags>
					<tag>
						<name>wd.author</name>
						<placement>a</placement>
						<head>Author:</head>
					</tag>
					<tag>
						<name>wd.example</name>
						<placement>a</placement>
						<head>Example:</head>
					</tag>
					<tag>
						<name>wd.notes</name>
						<placement>a</placement>
						<head>Notes:</head>
					</tag>
				</tags>
			</configuration>
			<executions>
				<execution>
					<id>attach-javadocs</id>
					<goals>
						<goal>jar</goal>
					</goals>
				</execution>
			</executions>
		</plugin>

		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-source-plugin</artifactId>
			<version>3.0.1</version>
			<executions>
				<execution>
					<id>attach-sources</id>
					<goals>
						<goal>jar</goal>
					</goals>
				</execution>
			</executions>
		</plugin>

		<plugin>
			<artifactId>maven-assembly-plugin</artifactId>
			<executions>
				<execution>
					<id>make-assembly</id>
					<phase>package</phase>
					<goals>
						<goal>single</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<descriptorRefs>
					<descriptorRef>jar-with-dependencies</descriptorRef>
				</descriptorRefs>
			</configuration>
		</plugin>
	</plugins>
</build>

<dependencies>
	<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
	<dependency>
		<groupId>commons-io</groupId>
		<artifactId>commons-io</artifactId>
		<version>1.3.2</version>
	</dependency>
	
	<dependency>
		<groupId>com.sun.mail</groupId>
		<artifactId>javax.mail</artifactId>
		<version>1.5.5</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
	<dependency>
		<groupId>commons-net</groupId>
		<artifactId>commons-net</artifactId>
		<version>3.3</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
	<dependency>
    	<groupId>org.apache.poi</groupId>
    	<artifactId>poi-ooxml</artifactId>
    	<version>3.17</version>
	</dependency>

</dependencies>	

Thanks!

I understad that you built the jar file of your common testing library outside KS using Maven with the pom.xml you shared above. I find you are using maven-assembly-plugin. This implies that your jar file is “fat”, which means the jar contains ALL of classes which your custom classes depend upon when it is executed standalone.

The pom.xml tells me that your custom classes depend on org.apache.poi:poi-ooxml:3.17. The poi-xml library reads/writes XML files. It certainly depends upon the Xerces XML parser API. Therefore your custom libary indirectly depends upon the Xerces.

The Xerces library is a classic; it is bundled in every versions of JDK since 1.4, …, Java 8, …, Java 11, …

I guess, you have built your jar using a version of JDK X (X not Java 8). Therefore your “fat jar” includes the class file of org.apache.xerces.dom.NodeImpl compiled by javac X (where X is not 8). Now, when you run a test in Katalon Studio, it uses the JRE version 8 in which another version of org.apache.xerces.dom.NodeImpl is bundled. Here arises a conflict.

How to workaround the conflict? — you should make your jar “fit” (not “fat”) so that it contains only the classes of your own hand, and no external dependencies included.

Hmm, that will be a little tricky, but where there’s a will there’s a way! Thanks for your help again!

Possibly you want to create both of “fat jar” and “fit jar”.

The following article tells how to:

Please note that this article uses maven-shade-plugin, not maven-assembly-plugin.

When you execute
$ mvn package

the standard maven-jar-plugin will generante target/yourlibname.jar which is “fit”.

Then maven-shade-plugin is invoked; it will rename it to

  • target/original-yourlibname.jar

this one is fit. And then the plugin generates one more jar named

  • target/yourlibname.jar

this one is fat.

Effectively you will obtain 2 jars; one is fit, another is fat.

1 Like

Also, you have more factors of conflict. The pom.xml shows that your library has extenal dependencies as follows:

  1. commons-io
  2. javax.mail
  3. commons-net
  4. poi-ooxml

On the other hand, you can see the list of KS-bundled libraries in the <projectDir>/.classpath file.

1, 2 and 4 (except commons-net) are already bundled in Katalon Studio, therefore these are likely to cause more of conflicts if your jar is “fat”.

Thanks, this is really useful info. It sounds like my next step is to create the fit jar and only copy this plus the one for commons-net into each Katalon project.