'Appium - Getting a java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() at PageFactory

I am getting this exception on running an Appium test. The test fails at PageFactory with the exception below.

My POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0`
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.telepathy.test</groupId>
    <artifactId>twitter</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>7.2.0</version>
        </dependency>
    </dependencies>

</project>

  • This was working fine up until yesterday, my machine got restarted and this error started coming.
  • Already tried with latest version of Appium (7.5.1)
  • Did mvn clean and refresh, update

Fails here: PageFactory.initElements(new AppiumFieldDecorator(this.driver), this);

java.lang.RuntimeException: java.lang.NoSuchMethodException: 
    jdk.proxy2.$Proxy9.proxyClassLookup()
    at  ​io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(
ApiumByBuilder.java:84)


Solution 1:[1]

You have to rebuild your project on java version 1.8 (which will be the minimum version), then you will have to insert your jre and jdk for version 15 or less and it should be fixed.

Solution 2:[2]

I also faced same issue but was not getting any solution for it. Just check you are using AppiumDriver instead of AndroidDriver. & You are using @FindBy annotation instead of @AndroidFindBy in your page object class. Also use PageFactory.initElements(driver, this); instead of PageFactory.initElements(new AppiumFieldDecorator(driver), this); This worked for me. It it works for you kindly acknowledge here. Thanks

Solution 3:[3]

I was getting same error but when I am running locally via eclipse it was working fine but when I am running via command line it was failing then I have added compile version in build i.e. gradle in my case. Similarly you can add in maven also it will solve the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gilbert
Solution 2 ouflak
Solution 3 Adrian Mole