Java.lang.LinkageError RFT – Selenium – Appium

huangapple go评论65阅读模式
英文:

Java.lang.LinkageError RFT - Selenium - Appium

问题

我陷入了这个境地,我已经审阅了许多文档,但找不到解决方法。我正在开发一个自动化处理网络和移动应用程序的项目,有时同时处理两者,因为它们之间必须传递信息。

当从IDE(RFT)本身运行时,自动化工作正常,但如果我尝试从控制台运行,它会抛出以下错误。

异常名称 = java.lang.LinkageError
异常消息 = 在创建类“io/appium/java_client/DefaultGenericMobileElement”时覆盖方法“org/openqa/selenium/remote/RemoteWebElement.findElement(Lorg/openqa/selenium/By;)Lorg/openqa/selenium/WebElement;”时的加载约束违规:类“io/appium/java_client/DefaultGenericMobileElement”的加载器“com/rational/test/ft/util/FtClassLoader@c6ae7474”和类“org/openqa/selenium/remote/RemoteWebElement”的加载器“com/rational/test/ft/util/FtClassLoader@a4fe6ba3”对于方法签名具有不同类型
脚本名称 = Platforms.Test.Test
脚本ID = Platforms.Test.Test.java
行号 = 40
异常堆栈 = 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)
...

这是我如何从命令行运行自动化脚本的方式,kernel.jar是与Ant一起打包的一组库,其中包括java-client-7.3.0 (io.appium.java_client),selenium.jar是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"

自动化脚本非常简单,它导入包含功能的类,这些功能使用selenium连接到web门户,检索安全码,然后使用appium使用该代码在应用程序中进行身份验证和其他操作,重申一下,如果我从IDE本身运行一切都是正常的。

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();
		}
	}
}

另一个重要的线索是,如果我从命令行运行仅实例化Selenium或仅实例化Appium的脚本,则不会显示java.lang.LinkageError,这表明命令是正确的。
通过控制台执行的原因是我远程执行这些操作,有数千个脚本,一个结束后我会开始执行另一个。

注意:
如果我使用已安装的Java虚拟机,则异常类似:

"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"

异常名称 = java.lang.LinkageError
异常消息 = 加载器约束违规:在解析被覆盖的方法“io.appium.java_client.DefaultGenericMobileDriver.findElementById(Ljava/lang/String;)Lorg/openqa/selenium/WebElement;”时,当前类的类加载器(com/rational/test/ft/util/FtClassLoader的实例)和其超类加载器(com/rational/test/ft/util/FtClassLoader的实例)对于在签名中使用的类型org/openqa/selenium/WebElement有不同的Class对象
英文:

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

答案1

得分: 0

我最终使用不同的触发命令解决了这个问题:

"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
英文:

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

huangapple
  • 本文由 发表于 2020年8月29日 00:25:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63637631.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定