Can't build Selenium standalone in java 11

前端 未结 4 611
失恋的感觉
失恋的感觉 2020-12-07 05:31

I am building a Java Selenium standalone application using Java11 in Eclipse 2018-12 but my builds fail:

java.lang.module.FindException: Unable to der

相关标签:
4条回答
  • 2020-12-07 05:32

    see here https://github.com/SeleniumHQ/selenium/wiki/Building-WebDriver

    The Java JDK 8 (note that versions 9 & 10 are not currently supported for building Selenium). Download it from Oracle's site if it's not already on your computer.

    0 讨论(0)
  • 2020-12-07 05:48

    This is due to a mistake in the .jar file. It contains a META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder entry, which, according to the jar service provider interface specification, must contain the name of a class in the same .jar file which implements the interface org.eclipse.jetty.http.HttpFieldPreEncoder.

    But, as the exception states, that service descriptor file contains org.eclipse.jetty.http.Http1FieldPreEncoder, a class which does not exist in the .jar file.

    There is, however, a org.seleniumhq.jetty9.http.Http1FieldPreEncoder class in the .jar.

    The easiest way to fix this is:

    • Extract the entire .jar to a temporary directory.
    • Change META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder so it contains the single line org.seleniumhq.jetty9.http.Http1FieldPreEncoder.
    • Create a new .jar file from the changed content.

    If you’re not in Windows, you can do it on the command line:

    mkdir -p META-INF/services
    echo org.seleniumhq.jetty9.http.Http1FieldPreEncoder > META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder
    zip -u -m selenium-server-standalone-3.141.59.jar META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder
    rm -r META-INF
    
    0 讨论(0)
  • 2020-12-07 05:52

    For me, it was that i only had to move the selenium.jar in my build path in libraries from modulepath to classpath. hope it helps.

    0 讨论(0)
  • 2020-12-07 05:52

    Encountered the same problem, defining all the jars in the classpath will serve the purpose.

    0 讨论(0)
提交回复
热议问题