How to resolve error in Katalon 8.5.2 - java.lang.ClassFormatError: Illegal method name

Hello guys. I am facing a new challenge when working with Katalon. I am fairly new to this software and I inherited some code I have to maintain. This code worked fine until suddenly it stopped working and generated this message:

=============== ROOT CAUSE =====================
Caused by: java.lang.ClassFormatError: Illegal method name “sitecore.ConnectToAPI.Authenticate_sitecore” in class CustomKeywords

The executed tests are written in Cucumber. There are some custom Keywords which are used in the tests. One of them is method called Authenticate_sitecore() which looks like this:

public static ResponseObject Authenticate_sitecore() {

		String requestMethod = "POST"

		TestObjectProperty header1 = new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/json")

		ArrayList defaultHeaders = Arrays.asList(header1)

		String body = '{"domain":"xxxx", "username":"yyyy", "password":"zzzz"}'

		RequestObject ro = new RequestObject("objectId")
		ro.setRestUrl(GlobalVariable.siteCoreURL + "/api/ssc/auth/login")
		ro.setHttpHeaderProperties(defaultHeaders)
		ro.setRestRequestMethod("POST")
		ro.setBodyContent(new HttpTextBodyContent(body))

		ResponseObject respObj = WS.sendRequest(ro)
		return respObj
	}

The class CustomKeywords in Libs folder does not contain any specific errors that I could notice:

Katalon does not show any problems with this method - the error is generated after executing the test. I did not change anything in this method since I took over the project.

Things I tried:

  1. Deleting bin and Libs folders and restarting Katalon - error reoccurs after Katalon is restarted and tests are run
  2. Updating Katalon to version 8.5.2
  3. Installing latest JRE 19 from Oracle

Any ideas how to fix this? I am considering downgrading to version 8.2.5

Katalon would not work on JRE19 from Oracle.
Katalon requires OpenJDK8. Check the doc: https://docs.katalon.com/docs/execute/katalon-runtime-engine/install-katalon-runtime-engine

Linux : Be sure to install OpenJDK 8 on your Ubuntu (NOT Oracle JDK).

why would you do that blindly?

simply because 19 > 8 doesn’t mean is better.
next time think twice

Interesting.

I forgot to mention that Katalon Studio is installed on Windows machine according to official docs, OpenJDK 8 is not required on Windows

Supported Environments | Katalon Docs

Installed OpenJdk amazon-corretto-17.0.5.8.1-windows-x64, issue still persists but only under very specific circumstances - after I switch between git branches, I keep receiving that error, and nothing helps - restarting Katalon Studio, deleting bin and Lib folders, etc.

What fixes the issue is rebooting the whole system and running the project again. Any ideas why that might happen?

I will try with OpenJdk 8. But I am wondering, why this should even be an issue? Especially, since I use JRE installed with Katalon:

Anyway, thank you for your respone @kazurayam . That was very helpful.

That is not helpful at all. Of course, 19>8 should mean it is better. And if it is not, Katalon Studio should return descriptive, easily understood exception message explaining what went wrong, instead of the user having to do the guesswork.

Also, as above, I work on Windows, so even according to official docs, global installation of JDK should not matter.

we have no idea what you did in addition to swithcing to a newest java, but that is also documented.
i am tired to do the search for you, but is in the docs

This makes me guess …

There is a subfoler named .cache in the project folder. In the .cache folder saved the compiled binaries of CustomKeywords, which will be re-used to skip compilation for quicker run.

Please try, in the git branch where you got the issue, remove the .cache folder + close the project + rerun. What does happen?

If removing the .cache folder fixes (I hope so), it suggests that the binary class file in the .cache was broken.

I do not know the reason why it was broken, and you do not need to find why. Anything breaks. I am afraid that Katalon Studio is implemented a bit buggy; it sometimes, though rarely, stores a broken binary into the .cache. All you can do is to remove the broken one and regenerate it cleanly.

I guess you have the .cache/ folder commited in your Git repository already. You must remove it out of the repository. And you want to change the .gitignore file so that it exclude the .cache/ folder. The .cache folder should never be committed into a git repository.


I think, the version of JRE has nothing to do with his case.

1 Like

I am tired of this topic. Katalon runtime needs openjdk8 at system level.
In windows environment that should be provided, indeed.
However you are playing with the JRE at compile the test time.
have fun with it and figure it out what is corrupted.

Thanks @kazurayam

The issue was indeed with .cache folder. The person that I took this project from did not add this folder to .gitignore, and it was filled in with old junk in the repo.

Additionally the issue occurred when I used Visual Studio Code for branch management, for some reason. Ever since I use just git bash console everything works fine.

I believe that VSCode is innocent of your issue.