Katalon Engine not correctly load Custom Keyword plugin

Hello,

I use private plugin inside Katalon Studio via JAR file inside Plugins folder. Everything works perfectly on my local machine. But when I use run via katalon engine (katalonc) inside Jenkins, plugin is not loaded.

Jenkins says:
INFO: Katalon Version: 8.3.0

Delete folder: bin
Delete folder: Libs
Cleaning up workspace
Opening project file: C:\jenkins…\katalon.prj
Warning! Please run Katalon execution command outside of the project folder.
Generating global variables…
Project ‘katalon’ opened
Start reloading plugins…
Katalon version: 8.3.0

Plugin name: UploadFile Keywords. Is online: true. Plugin location: C:\katalon_engine\configuration\plugin\install\211412\1.0.0\katalon-studio-uploadfile-plugin.jar.

---- custom private plugin loading
Plugin name: katalon-keywords-0.0.2.jar. Is online: false. Plugin location: C:\jenkins…\Plugins\katalon-keywords-0.0.2.jar.

Plugin “UploadFile Keywords” has been installed.¨
Plugin “katalon-keywords-0.0.2.jar” has been installed.
Start check license task

INFO: KATALON_JAVA_HOME: null

And there is the problem. I don’t know why, but the custom keywords from plugin are not available. Plugin katalon-keywords-0.0.2.jar is inside Plugins folder. On my local machine Katalone run Build while opening project and create CustomKeywords.groovy inside Libs folder. But on remote machine doesn’t. And show error:

Caught: java.lang.ClassFormatError: Illegal method name "cz.helpers.CAS.login" in class CustomKeywords
java.lang.ClassFormatError: Illegal method name "cz.helpers.CAS.login" in class CustomKeywords
	at com.kms.katalon.core.main.TestCaseMain.modifyCustomKeywordsClassAtRunTime(TestCaseMain.java:118)
	at com.kms.katalon.core.main.TestCaseMain.beforeStart(TestCaseMain.java:62)
	at com.kms.katalon.core.main.TestCaseMain$beforeStart.call(Unknown Source)
	at TempTestSuite1652367154923.run(TempTestSuite1652367154923.groovy:34)
Launcher status after execution process completed: Running

Do you have any idea what is wrong?
Thanks for you advice,
Roman.

What do you mean by saying “doesn’t”?

  1. there is no CustomKeywords.groovy file in the Libs directory of the remote project
  2. there is a CustomKeywords.groovy file, but it does not contain the statement:
def static "cz.helpers.CAS.login"(
    ...
}
  1. there is a CustomKeywords.groovy file which contains the statement as above. But an error occures.

java.lang.ClassFormatError: Illegal method name “cz.helpers.CAS.login” in class CustomKeywords

This message seems to be suggesing the case 2.

In the log you got

Plugin “katalon-keywords-0.0.2.jar” has been installed.

This message implies that the jar was found in the Katalon Plugin Store, and the katalonc succeeded downloading the jar from the Store and installing the jar into the project, but you got an error.

This suggests that the jar has something wrong.

Can you make sure the jar on the remote machine contains the cz.helpers.CAS class? You can get the list of contained flies by the command line command.

jar --list --file jarName.

If the jar does NOT contain the cz.helpers.CAS class, it implies that you failed to update the jar version in the repository of Katalon Plugin Store to the latest.

Or, the cz.helpers.CAS class in the jar on the remote machine may lack the method login().

Please check.

Hi kazurayam,

thanks for your replies.

About first reply. I know the error looks like second case. But it is case number 1. File is not created on remote machine. I try to add file CustomKeywords.groovy to git. Pull him on remote machine. But katalonc clear the Libs folder when start. And then make some .groovy files inside Libs folder. But without CustomKeywords.groovy file. So, I thinks this is the problem. Under bin/lib is CustomKeywords.class but without the keywords from JAR file.

About second reply. The katalon-keywords-0.0.2.jar file is private plugin. Not from Katalon Store (as others plugin). I use our private Nexus. And when i copy the JAR file from local to remote machine, nothing change. So I think, the JAR file is OK, because work on local machine as well.

When i install Katalon Studio on remote machine and open the same project (same folder), everything work as expected. As on local machine. And Katalon Studio make valid Libs/CustomKeyword.groovy file with keywords from plugin.

This command run katalonc:
C:\jenkins\...\workspace\_gradle_keywords>C:\katalon_engine\katalonc -licenseRelease=true -runMode=console -browserType=Chrome -propertiesFile="C:\jenkins\...\workspace\_gradle_keywords\Jenkins\console.properties" -projectPath="C:\jenkins\..\workspace\_gradle_keywords\katalon-gpk.prj" -apiKey="****" --config -proxy.auth.option=MANUAL_CONFIG -proxy.auth.server.type=HTTP -proxy.auth.server.address=**** -proxy.auth.server.port=**** -proxy.system.option=MANUAL_CONFIG -proxy.system.server.type=HTTP -proxy.system.server.address=**** -proxy.system.server.port=**** -proxy.system.applyToDesiredCapabilities=true -webui.autoUpdateDrivers=true

Output from remote katalon-keywords-0.0.2.jar is:

tech/gradle_keywords $ jar --list --file katalon-keywords-0.0.2.jar                                                                                      
META-INF/
META-INF/MANIFEST.MF
...
cz/helpers/CAS.class ---> there is the CAS class
...
internal/GlobalVariable.class
TempTestCase1652088225176.class
CustomKeywords.class  ---> there is the CAS.login keyword map
katalon-plugin.json ---> there is the CAS.groovy path "cz.helpers.CAS"

So if the JAR file will be wrong, same problem will be on my local machine or on remote machine under Katalon Studio run. I read documentation but didn’t find any command for force build katalon keywords from katalon engine/katalonc (as do Katalon Studio when I open project).

Thanks.

Interesting. It seems to be a problem of Katalon Runtime Engine.

@duyluong

By the way, do you really need CustomKeyword.groovy? I guess, you would not need it at all.

You have a class cz.helpers.CAS with a method login() in your jar, and you are sure your project has that jar in the classth. The the following code in a Test Case would work.

import cz.helpers.CAS

CAS.login()

You don’t need to write:

CustomKeywords.'cz.helpers.CAS.login'()

How about locating your katalon-keywords-0.0.2.jar into the Drivers folder rather than Plugins folder. It may work.

Yes, we need use Custom keyword logic. I totally understand what you mean. But our main users who use Katalon are testers. And these guys hasn’t knowledge about programming. So they use Katalon Studio UI and add each command via tables (manual tab) in Katalon Studio. It was one of main reasons, why we choose this product.

When I place JAR file to Drivers instead of Plugin, Katalon Engine show same error. Katalon Studio run tests but didn’t suggest our custom keywords in manual adding. So this is not the way for ours.

Thanks.

I guess that Katalon Runtime Engine generated the CustomKeywords.groovy file and saved somewhere you do not expect it to.

I guess so because the -projectPath parameter you give in the command line looks strange to me.

Sorry, the path is without dots. I just anonymize information, because this is public site. So, the path is -projectPath=“C:\jenkins\<some folders>\workspace_gradle_keywords\katalon-gpk.prj”

Do you find the CustomKeywords.groovy file anywhere?

Unfortunately didn’t find.