Running a test may cause java.lang.ClassFormatError: Truncated class file

Hello, when I try to run test scripts or suites, I get this error showing up in the console fairly often since upgrading to Katalon Studio 8.x. I’m not sure what could be causing this. It’s not consistent. I know this.

Caught: java.lang.ClassFormatError: Truncated class file
java.lang.ClassFormatError: Truncated class file
	at com.kms.katalon.core.main.TestCaseMain.modifyCustomKeywordsClassAtRunTime(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.beforeStart(TestCaseMain.java:62)
	at com.kms.katalon.core.main.TestCaseMain$beforeStart.call(Unknown Source)
	at TempTestCase1638561942208.run(TempTestCase1638561942208.groovy:23)
1 Like

Perhaps you should do “clean build” in the upgraded version once.

You want to

  1. stop Katalon Studio
  2. in Windows Explorer, open the project folder
  3. delete <projectDir>/bin folder,
  4. delete <projectDir>/Libs folder
  5. delete <projectDir>/.cache folder
  6. restart KS, open the project and see

Same here.

I’ve done what @kazurayam has suggested but after a while I got the same error again.

Could you try installing Katalon Studio again?

I’m now getting this error as well. I’m using KS 8.2 (build 208). Sometimes it work but not really sure what happened. Only happens when doing the test suite. Seems fine when doing test case. Is there a change when doing iteration in data files?

@kazurayam, Deleting the bin & Libs folder, is helping for the first run only.

When you run the second time, the same issue is occurring.

@kazurayam Please find below, the steps to reproduce in V8.2

  1. Firstly create a Custom Keyword as below.
    CustomKeywords.‘util.Launch.test’()
    Note: I have few application in my organization which work only in IE browser, but the integration web apps works in modern browser. So I am using this keyword to handle the scenario.

  2. Ensure your default browser is other than IE browser.
    image

  3. To reproduce this issue. Call the CustomKeywords.‘util.Launch.test’() in Testcase. The very first execution works without issue. When you rerun the same testcase, you get the error as mentioned in the thread.

package util

import org.openqa.selenium.WebDriver
import org.openqa.selenium.ie.InternetExplorerDriver

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

/**
irrespective of the browser selected during execution, the below keyword opens only in  IE browser.
*/

public class Launch {
	
	@Keyword
	public static void test() {
		
		String path = RunConfiguration.getProjectDir() + "/driver/IEDriverServer.exe"
		
		System.setProperty('webdriver.ie.driver', path)
		
		WebDriver driver = new InternetExplorerDriver()
		
		DriverFactory.changeWebDriver(driver)
		
		WebUI.navigateToUrl('https://www.google.co.in/')
		
	}
}

@devalex88 @duyluong @Jass

No, I couldn’t reproduce it on my machine.

Please try the below:

  1. Close the project by selecting Project-> Close and Clean Up.
  2. Run the Testcase with keyword CustomKeywords.‘util.Launch.test’() in chrome browser.
  3. The Test will launch in IE browser and work as expected.
  4. Rerun the testcase in chrome browser. Now the script should fail,

See

In v8.2.0, we did improve KRE to prevent loading custom keywords when opening project …

@duyluong
@Jass
@Shin
@chrisstu

I believe that the change made at v8.2.0 has a fault that causes an Exception “java.lang.ClassFormatError: Truncated class file” as reported by @abrombacher, @kaique.silveira, @david.casiano, @discover.selenium

The “ java.lang.ClassFormatError: Truncated class file ” Exception is raised by com.kms.katalon.core.main.TestCaseMain class at modifyCustomKeywordClassAtRunTime() method because the class file of a Custom Keyword is corrupted (possibly empty). Why? Because of the change you made for performance improvement at v8.2.0, I suppose.

2 Likes

@Russ_Thomas

Could you move this to “Bugs” category?

1 Like

Could you try one more step:

  1. delete <projectDir>/.cache folder
1 Like

Thanks @kazurayam, deleting the .cache folder helped to solve the problem.

Hello, I tried reinstalling, but it did not work. I’m using Katalon on Mac by the way. I will attempt @discover.selenium 's method next time.

@duyluong

Please put this bug into your tracking system.

2 Likes

Hi All,

Kindly be informed this bug is fixed in version 8.2.5. Please download our latest release 8.2.5 for trying out.

  • Bug details: Editing script and executing a test could intermittently cause the error: “java.lang.ClassFormatError: Truncated class file”.

See more updates in this release at Release notes 8.2.5.

Regards,
Shin

2 Likes