SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.65k stars 8.18k forks source link

[🐛 Bug]: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException #13289

Closed jjqi92 closed 10 months ago

jjqi92 commented 10 months ago

What happened?

when i execute : java -Dwebdriver.http.factory=jdk-http-client --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -jar selenium-server-4.15.0.jar --ext selenium-http-jdk-client-4.13.0.jar standalone it appends exception: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77) at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70) Caused by: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:119) at org.openqa.selenium.grid.node.config.NodeOptions.getNode(NodeOptions.java:166) at org.openqa.selenium.grid.commands.Standalone.createHandlers(Standalone.java:217) at org.openqa.selenium.grid.TemplateGridServerCommand.asServer(TemplateGridServerCommand.java:47) at org.openqa.selenium.grid.commands.Standalone.execute(Standalone.java:262) at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$4(TemplateGridCommand.java:122) at org.openqa.selenium.grid.Main.launch(Main.java:83) at org.openqa.selenium.grid.Main.go(Main.java:56) at org.openqa.selenium.grid.Main.main(Main.java:41) ... 6 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.openqa.selenium.grid.config.ClassCreation.callCreateMethod(ClassCreation.java:51) at org.openqa.selenium.grid.config.MemoizedConfig.lambda$getClass$4(MemoizedConfig.java:104) at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737) at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:99) ... 14 more Caused by: org.openqa.selenium.grid.config.ConfigException: No drivers have been configured or have been found on PATH at org.openqa.selenium.grid.node.config.NodeOptions.addDetectedDrivers(NodeOptions.java:513) at org.openqa.selenium.grid.node.config.NodeOptions.getSessionFactories(NodeOptions.java:232) at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:79) ... 22 more

How can we reproduce the issue?

execute this cmd:
 java -Dwebdriver.http.factory=jdk-http-client --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -jar selenium-server-4.15.0.jar --ext selenium-http-jdk-client-4.13.0.jar standalone

Relevant log output

11:25:32.050 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
11:25:32.069 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
11:25:33.059 INFO [NodeOptions.getSessionFactories] - Detected 3 available processors
11:25:33.062 INFO [NodeOptions.discoverDrivers] - Looking for existing drivers on the PATH.
11:25:33.062 INFO [NodeOptions.discoverDrivers] - Add '--selenium-manager true' to the startup command to setup drivers automatically.
11:25:33.210 WARN [SeleniumManager.lambda$runCommand$1] - Unable to discover proper chromedriver version in offline mode
11:25:33.240 WARN [SeleniumManager.lambda$runCommand$1] - Unable to discover proper msedgedriver version in offline mode
11:25:33.260 WARN [SeleniumManager.lambda$runCommand$1] - Unable to discover proper geckodriver version in offline mode
11:25:33.274 WARN [NodeOptions.addDetectedDrivers] - No drivers have been configured or have been found on PATH
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77)
        at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70)
Caused by: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException
        at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:119)
        at org.openqa.selenium.grid.node.config.NodeOptions.getNode(NodeOptions.java:166)
        at org.openqa.selenium.grid.commands.Standalone.createHandlers(Standalone.java:217)
        at org.openqa.selenium.grid.TemplateGridServerCommand.asServer(TemplateGridServerCommand.java:47)
        at org.openqa.selenium.grid.commands.Standalone.execute(Standalone.java:262)
        at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$4(TemplateGridCommand.java:122)
        at org.openqa.selenium.grid.Main.launch(Main.java:83)
        at org.openqa.selenium.grid.Main.go(Main.java:56)
        at org.openqa.selenium.grid.Main.main(Main.java:41)
        ... 6 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.openqa.selenium.grid.config.ClassCreation.callCreateMethod(ClassCreation.java:51)
        at org.openqa.selenium.grid.config.MemoizedConfig.lambda$getClass$4(MemoizedConfig.java:104)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737)
        at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:99)
        ... 14 more
Caused by: org.openqa.selenium.grid.config.ConfigException: No drivers have been configured or have been found on PATH
        at org.openqa.selenium.grid.node.config.NodeOptions.addDetectedDrivers(NodeOptions.java:513)
        at org.openqa.selenium.grid.node.config.NodeOptions.getSessionFactories(NodeOptions.java:232)
        at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:79)
        ... 22 more

Operating System

linux

Selenium version

java11 selenium4.15.0

What are the browser(s) and version(s) where you see this issue?

no

What are the browser driver(s) and version(s) where you see this issue?

no

Are you using Selenium Grid?

4.15.0

github-actions[bot] commented 10 months ago

@jjqi92, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

krmahadevan commented 10 months ago

@jjqi92 - The latest released version of selenium server is 4.16.1 Can you please retry again with that?

I tried the below example on an ubuntu machine and it worked fine.

java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -jar selenium-server-4.16.1.jar standalone

And oh btw, I think now the JDK client is the default http client and you don't need to be specifying that jar explicitly via the --ext argument.

If you noticed any errors, please help share the complete output and not just the stacktrace. That way it would be easy to debug

jjqi92 commented 10 months ago

I think I may have used the wrong command. i want to register hub, so i use new cmd: java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -jar selenium-server-4.16.1.jar hub

15:41:15.152 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding 15:41:15.173 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing 15:41:15.320 INFO [BoundZmqEventBus.] - XPUB binding to [binding to tcp://:4442, advertising as tcp://10.130.246.110:4442], XSUB binding to [binding to tcp://:4443, advertising as tcp://10.130.246.110:4443] 15:41:15.403 INFO [UnboundZmqEventBus.] - Connecting to tcp://10.130.246.110:4442 and tcp://10.130.246.110:4443 15:41:15.438 INFO [UnboundZmqEventBus.] - Sockets created 15:41:16.439 INFO [UnboundZmqEventBus.] - Event bus ready WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/opt/tomcat/bin/selenium-server-4.16.1.jar) to constructor java.nio.DirectByteBuffer(long,int) WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 15:41:17.399 INFO [Hub.execute] - Started Selenium Hub 4.16.1 (revision 9b4c83354e):

it seems started, but it still prompts error when i create a driver via code.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("browserVersion", "100");
chromeOptions.setCapability("platformName", "Windows");
driver = new RemoteWebDriver(new URL("http://xxx:4444"), chromeOptions);

it prompts exception: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException Build info: version: '4.15.0', revision: '1d14b5521b' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.14.1' Driver info: driver.version: RemoteWebDriver

can you help me take a look this problem?

pujagani commented 10 months ago

Can you share the complete logs of Hub and the Node? It will help us understand if the node registered properly with the hub. Also, please try the latest version, 4.16.1.

jjqi92 commented 10 months ago

hub log:

[deploy@r100021942-71071997-s44rq bin]$ java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -jar selenium-server-4.16.1.jar hub
15:41:15.152 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding 15:41:15.173 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing 15:41:15.320 INFO [BoundZmqEventBus.] - XPUB binding to [binding to tcp://:4442, advertising as tcp://10.130.246.110:4442], XSUB binding to [binding to tcp://:4443, advertising as tcp://10.130.246.110:4443] 15:41:15.403 INFO [UnboundZmqEventBus.] - Connecting to tcp://10.130.246.110:4442 and tcp://10.130.246.110:4443 15:41:15.438 INFO [UnboundZmqEventBus.] - Sockets created 15:41:16.439 INFO [UnboundZmqEventBus.] - Event bus ready WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/opt/tomcat/bin/selenium-server-4.16.1.jar) to constructor java.nio.DirectByteBuffer(long,int) WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 15:41:17.399 INFO [Hub.execute] - Started Selenium Hub 4.16.1 (revision 9b4c83354e): http://10.130.246.110:4444 15:46:44.402 INFO [Node.] - Binding additional locator mechanisms: relative 15:46:55.338 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:05.346 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:15.354 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:25.373 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:35.387 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:45.402 INFO [Node.] - Binding additional locator mechanisms: relative 15:47:55.410 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:05.420 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:15.430 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:25.438 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:35.446 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:45.457 INFO [Node.] - Binding additional locator mechanisms: relative 15:48:55.465 INFO [Node.] - Binding additional locator mechanisms: relative 15:49:05.474 INFO [Node.] - Binding additional locator mechanisms: relative 15:49:44.123 INFO [Node.] - Binding additional locator mechanisms: relative 15:50:44.119 INFO [Node.] - Binding additional locator mechanisms: relative 15:51:44.112 INFO [Node.] - Binding additional locator mechanisms: relative 15:52:19.571 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "3ea671994a3e6456bf679090470af3a0","eventTime": 1702367539546412108,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "10.130.246.110:4444","http.method": "POST","http.request_content_length": "888","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f4.15.0 (java windows)"}}

15:52:44.120 INFO [Node.] - Binding additional locator mechanisms: relative 15:53:44.123 INFO [Node.] - Binding additional locator mechanisms: relative 15:54:44.129 INFO [Node.] - Binding additional locator mechanisms: relative 15:55:19.424 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "b5d74693d1c3a0114077c9cc4dab4e7d","eventTime": 1702367719423665866,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "10.130.246.110:4444","http.method": "POST","http.request_content_length": "283","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f4.15.0 (java windows)"}}

15:55:44.106 INFO [Node.] - Binding additional locator mechanisms: relative

node log:

15:46:41.250 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding 15:46:41.257 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing 15:46:41.391 INFO [UnboundZmqEventBus.] - Connecting to tcp://10.130.246.110:4442 and tcp://10.130.246.110:4443 15:46:41.430 INFO [UnboundZmqEventBus.] - Sockets created 15:46:42.444 INFO [UnboundZmqEventBus.] - Event bus ready 15:46:42.591 INFO [NodeServer.createHandlers] - Reporting self as: http://2.0.0.1:5555 15:46:42.692 INFO [NodeOptions.getSessionFactories] - Detected 12 available processors 15:46:43.995 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox","platformName": "Windows 10"} 12 times 15:46:43.996 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge","platformName": "Windows 10"} 12 times 15:46:43.996 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome","platformName": "Windows 10"} 12 times 15:46:43.997 INFO [NodeOptions.report] - Adding Internet Explorer for {"browserName": "internet explorer","platformName": "Windows 10"} 1 times 15:46:44.039 INFO [Node.] - Binding additional locator mechanisms: relative WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/D:/node/selenium-server-4.16.1.jar) to constructor java.nio.DirectByteBuffer(long,int) WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 15:46:44.278 INFO [NodeServer$1.start] - Starting registration process for Node http://2.0.0.1:5555 15:46:44.279 INFO [NodeServer.execute] - Started Selenium node 4.16.1 (revision 9b4c83354e): http://2.0.0.1:5555 15:46:44.295 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:46:54.308 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:04.317 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:14.324 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:24.341 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:34.348 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:44.354 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:47:54.359 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:48:04.364 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:48:14.381 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:48:24.398 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:48:34.416 INFO [NodeServer$1.lambda$start$1] - Sending registration event... 15:48:44.281 INFO [NodeServer$1.lambda$start$1] - Sending registration event...

jjqi92 commented 10 months ago

@pujagani The complete log has been added.

krmahadevan commented 10 months ago

@jjqi92 - It looks like the node is resolving to an internal IP address which is what it is using to register itself to the hub.

During registration, when the node sends a registration request to the hub, the hub uses the IP address sent by the node, to periodically poll the node to determine if its reachable and if its not reachable, it gets rid of it and the node continues to try and register itself.

That explains why you keep seeing so many "Sending Registration event" messages.

You would need to find out what is the publicly reachable IP address of the machine where your node runs and use that through the command line arg --host when spawning the node.

You can perhaps refer to this post to find out how to determine your private and public ip addresses (usually happens when there are more than 1 network interface i believe) https://askubuntu.com/q/1153964

diemol commented 10 months ago

Thanks @krmahadevan and @pujagani for troubleshooting.

Yes, you need to follow what @krmahadevan is suggesting. I will mark this as a question and it will get closed, but feel free to continue the conversation if you wish.

github-actions[bot] commented 10 months ago

💬 Please ask questions at:

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.