I am stuck in this situation, I have reviewed a lot of documentation but I cannot find the solution, I am working on a project that automates web and mobile apps, and sometimes both at the same time, because there is information that must be transferred between them.
The automations work correctly when run from the IDE (RFT) itself, but if I try to run it from the console it throws the following error.
exception_name = java.lang.LinkageError
exception_message = loading constraint violation when overriding method "org/openqa/selenium/remote/RemoteWebElement.findElement(Lorg/openqa/selenium/By;)Lorg/openqa/selenium/WebElement;" during creation of class "io/appium/java_client/DefaultGenericMobileElement": loader "com/rational/test/ft/util/FtClassLoader@c6ae7474" of class "io/appium/java_client/DefaultGenericMobileElement" and loader "com/rational/test/ft/util/FtClassLoader@a4fe6ba3" of class "org/openqa/selenium/remote/RemoteWebElement" have different types for the method signature
script_name = Platforms.Test.Test
script_id = Platforms.Test.Test.java
line_number = 40
exception_stack = at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at com.rational.test.ft.util.FtClassLoader.callRelatedClassLoaders(FtClassLoader.java:356)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:163)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at Platforms.Test.Test.testMain(Test.java:40)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
at org.eclipse.core.launcher.Main.main(Main.java:34)
This is how I run the automation from the command line, kernel.jar is a set of libraries packed with Ant that among others contains java-client-7.3.0 (io.appium.java_client), selenium.jar is selenium-server-standalone-3.141.59 (org.openqa. selenium):
"C:\Program Files\IBM\SDP\jdk\bin\java" -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
The automation script is very simple, it imports a classes that contains the functionalities, which using selenium connects to a web portal, retrieves a security code and then using appium uses that code to authenticate in an app and do other operations, which I repeat everything works correctly if I run from the IDE itself.
public class Test extends TestHelper
{
/**
*
* @since 2020/08/21
* @author jddeltoro
*/
public void testMain(Object[] args)
{
Framework fw = Framework.getInstance();
try {
fw.initEnviromentTokens();
WebAppAutomation waa= new WebAppAutomation(fw);
waa.init();
String code = wpa.reatriveSecurityCode();
waa.quit();
MobileAppAutomation maa= new MobileAppAutomation(fw);
maa.init();
maa.executeProcess(code);
maa.quit();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Another important clue is that if I run a script from the command line that instantiates only Selenium or only Appium, the java.lang.LinkageError is not displayed, this indicates that the command is correct. The reason for executing through the console is that I carry out the executions remotely, there are thousands of scripts and when one finishes I start the execution of another.
Note: If i use installed java vm the exception is similar:
"java -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
exception_name = java.lang.LinkageError
exception_message = loader constraint violation: when resolving overridden method "io.appium.java_client.DefaultGenericMobileDriver.findElementById(Ljava/lang/String;)Lorg/openqa/selenium/WebElement;" the class loader (instance of com/rational/test/ft/util/FtClassLoader) of the current class, io/appium/java_client/DefaultGenericMobileDriver, and its superclass loader (instance of com/rational/test/ft/util/FtClassLoader), have different Class objects for the type org/openqa/selenium/WebElement used in the signature
I finally solve this using a different trigger command:
"C:\Program Files\IBM\SDP\jdk\bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar;C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -projectpath C:\Workspaces\RFT\Project -datastore C:\Workspaces\RFT\Project -idetype wswplugin -rt.interactive true -rt.log_format html -log Platforms.Test.Test -iterationcount ALL -rt.log_action false -rt.log_screen_snapshot false -playback Platforms.Test.Test