Can't build Selenium standalone in java 11

前端 未结 4 618
失恋的感觉
失恋的感觉 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条回答
  •  猫巷女王i
    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
    

提交回复
热议问题