java-client: Getting java.lang.NoSuchMethodException when loading PageFactory elements in Java16+
Description
Failed to switch to Java 17 due to issue with running Appium tests:
Caused by:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
Caused by:
java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy119.proxyClassLookup()
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(AppiumByBuilder.java:84)
Caused by:
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.getFilledValue(AppiumByBuilder.java:91)
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.createBy(AppiumByBuilder.java:147)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.getBys(DefaultElementByBuilder.java:133)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildMobileNativeBy(DefaultElementByBuilder.java:170)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildBy(DefaultElementByBuilder.java:204)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:66)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:53)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:1)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:56)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:154)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
...
at ui.pageobject.ringapp.common.AbstractMobileViewWithHeader.<init>(AbstractMobileViewWithHeader.java:104)
at ui.pageobject.ringapp.devicedetail.ActivateSirenPopupView.<init>(ActivateSirenPopupView.java:9)
... 60 more
Caused by:
java.lang.NoSuchMethodException: jdk.proxy2.$Proxy119.proxyClassLookup()
at java.base/java.lang.Class.getMethod(Class.java:2227)
Caused by:
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(AppiumByBuilder.java:82)
... 76 more
Java 16 also failed. Java 15 is OK.
Environment
- Java client build version or git revision if you use some snapshot: 17
- Appium server version or git revision if you use some snapshot: 1.22.0
- Desktop OS/version used to run Appium if necessary: MacOs Big Sur 11.6
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 12.18.3
- Mobile platform/version under test: iOS/Android
- Real device or emulator/simulator: real
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (10 by maintainers)
Commits related to this issue
- Filter out proxyClassLookup method from Proxy class (for Java 16+) in AppiumByBuilder. [#1575](https://github.com/appium/java-client/issues/1575) — committed to ayuryev/java-client by ayuryev 3 years ago
- Filter out proxyClassLookup method from Proxy class (for Java 16+) in AppiumByBuilder. [#1575](https://github.com/appium/java-client/issues/1575) — committed to ayuryev/java-client by ayuryev 3 years ago
@mykola-mokhnach could you merge this fix into 7.6.x version? Thank you
We’d like to publish a new beta as soon as there is a new selenium lib patch available. See https://github.com/appium/java-client/issues/1608 for more details
@mykola-mokhnach Dear Mykola, we’ve faced with the similar problem on our project, it will be wonderful if it is possible to fix into 7 version. Thank you in advance.
@margasan We currently aim to release version 8 and will only be supporting that one. Consider creating a custom fork if you’d like to continue using v7
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork