Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

RemoteWebDriver throws exception when opening new sesssion #2091

Closed
lukeis opened this issue Mar 2, 2016 · 16 comments
Closed

RemoteWebDriver throws exception when opening new sesssion #2091

lukeis opened this issue Mar 2, 2016 · 16 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 2091

What steps will reproduce the problem?

1. Install selenium-server-standalone-2.1.0
2. Try to create a new session via RemoteWebDriver with the following desired capabilities:

{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":false,"browserName":"firefox"}}

What is the expected output? What do you see instead?

It is expected that no exceptions are dumped into the server log nor in the response
body. Instead I see an exception in the log, as well as in the response body. However,
I am able to proceed because the session is created and the outer response header is
good (302).

Selenium version: 2.1.0
OS: Linux 2.6.32-33-generic i386
Browser: Firefox 
Brower version: 3.6.18

This is a captured TCP conversation:


POST /wd/hub/session HTTP/1.1
Host: localhost:4444
Accept: /
Content-Length: 95
Content-Type: application/x-www-form-urlencoded

{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":false,"browserName":"firefox"}}HTTP/1.1
302 Moved Temporarily
Date: Wed, 20 Jul 2011 11:03:38 GMT
Server: Jetty/5.1.x (Linux/2.6.32-33-generic i386 java/1.6.0_26
Location: http://localhost:4444/wd/hub/session/1311158805866
Content-Length: 0

GET /wd/hub/session/1311158805866 HTTP/1.1
Host: localhost:4444
Accept: /

HTTP/1.1 500 java%2Eutil%2Econcurrent%2EExecutionException%3A+java%2Elang%2ENullPointerException
Date: Wed, 20 Jul 2011 11:03:43 GMT
Server: Jetty/5.1.x (Linux/2.6.32-33-generic i386 java/1.6.0_26
Content-Length: 1365
Content-Type: text/html
Connection: close

<title>Error 500 java.util.concurrent.ExecutionException: java.lang.NullPointerException</title>

HTTP ERROR: 500

java.util.concurrent.ExecutionException: java.lang.NullPointerException

RequestURI=/wd/hub/session/1311158805866

Powered by Jetty://


Log file with the exception is attached.

Reported by sergey.tsivin on 2011-07-20 11:11:33


- _Attachment: [selenium.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-2091/comment-0/selenium.log)_
@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I just realized that unhandled excpetion occurs not when creating a new session but
when trying to get the session capabilities. It is expected that it will return an
json object describing the session's capabilities. 

The second request was auto-generated by curl because I was using curl with CURLOPT_FOLLOWLOCATION
set to TRUE.


Reported by sergey.tsivin on 2011-07-20 11:37:26

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I seem to have the same problem, I have tried with 2.7.0, 2.6.0 and 2.1.0 on OSX and
windows with the same results:

19:27:48.041 INFO - Executing: [new session: {javascriptEnabled=true, browserName=firefox,
nativeEvents=false, version=}] at URL: /session)
19:27:53.805 INFO - Done: /session
19:27:53.820 INFO - Executing: org.openqa.selenium.remote.server.handler.GetSessionCapabilities@114b82b
at URL: /session/1316917522459)
19:27:53.822 INFO - Done: /session/1316917522459
19:27:53.823 INFO - WebDriver remote server: Fatal, unhandled exception: /session/1316917522459:
java.util.concurrent.ExecutionException: java.lang.NullPointerException
19:27:53.824 WARN - EXCEPTION
javax.servlet.ServletException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:454)
        at org.openqa.selenium.remote.server.DriverServlet.doGet(DriverServlet.java:426)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
        at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
        at java.util.concurrent.FutureTask.get(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:118)
        at org.openqa.selenium.remote.server.handler.WebDriverHandler.execute(WebDriverHandler.java:90)
        at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:203)
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:450)
        ... 15 more
Caused by: java.lang.NullPointerException
        at org.openqa.selenium.remote.server.renderer.ForwardResult.render(ForwardResult.java:39)
        at org.openqa.selenium.remote.server.rest.ResultConfig$1.call(ResultConfig.java:198)
        at org.openqa.selenium.remote.server.rest.ResultConfig$1.call(ResultConfig.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
19:27:53.838 WARN - /wd/hub/session/1316917522459:
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
        at java.util.concurrent.FutureTask.get(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:118)
        at org.openqa.selenium.remote.server.handler.WebDriverHandler.execute(WebDriverHandler.java:90)
        at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:203)
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:450)
        at org.openqa.selenium.remote.server.DriverServlet.doGet(DriverServlet.java:426)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
        at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: java.lang.NullPointerException
        at org.openqa.selenium.remote.server.renderer.ForwardResult.render(ForwardResult.java:39)
        at org.openqa.selenium.remote.server.rest.ResultConfig$1.call(ResultConfig.java:198)
        at org.openqa.selenium.remote.server.rest.ResultConfig$1.call(ResultConfig.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
19:27:53.883 INFO - Executing: [get: http://www.yahoo.com] at URL: /session/1316917522459/url)
19:27:55.570 INFO - Done: /session/1316917522459/url
19:27:55.590 INFO - Executing: [find element: By.tagName: a] at URL: /session/1316917522459/element)
19:27:55.886 INFO - Done: /session/1316917522459/element
19:27:55.902 INFO - Executing: [delete session: 1316917522459] at URL: /session/1316917522459)
19:27:57.215 INFO - Done: /session/1316917522459

Reported by ysaberi on 2011-09-25 11:37:02

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

What WebDriver client / language binding are you guys using? 

Even though we should do better than throwing NPEs on client side bugs, this isn't
something we've seen with the official language bindings. 

Reported by jari.bakken on 2011-09-25 19:03:34

  • Status changed: NeedsClarification
  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I was using one of the php driver (https://github.com/chibimagic/WebDriver-PHP) when
this exception occured. However when I switched to the other php driver (http://code.google.com/p/php-webdriver-bindings/)
the problem does not occur any longer. So it would seem the issue at least for was
with the first php library.

Reported by ysaberi on 2011-09-26 17:45:49

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Same bug shows up with the facebook-php-webdriver-3771050 driver.

Reported by vesselin.atanasov on 2011-12-19 07:18:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Since we have some posts about using the unsupported PHP bindings, it would help if
one knows enough code, to see how each of the PHP drivers is implementing the (desired)
capabilities request when starting a new session.

And if this has nothing to do with capabilities (for the issues seen in PHP), then
see how each of the PHP drivers implement the request to start new session.

By comparing the code, hopefully we can tell why it happens on some but not all of
the PHP bindings.

Reported by mangaroo on 2011-12-23 01:35:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

They are the curl commands that reproduce the error:

curl -v -X POST http://localhost:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"firefox"}}'
curl -v 'http://localhost:4444/wd/hub/session/SESSION_ID'

Replace the SESSION_ID returned from the first curl.


Reported by tszming on 2012-01-06 05:54:03

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I can confirm that this is still happening with  v2.16.1 and v2.17.0, both with normal
usage and the curl actions that tszm posted above.  I also got the same error using
http://code.google.com/p/php-webdriver-bindings/ code, so I don't think it's a case
of one set of PHP bindings being broken.

I renders webdriver entirely unusable as far as I can see. :-\

Reported by sam@silverstripe.com on 2012-01-19 00:24:35

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Attached is a transcript of HTTP requests and responses that demonstrate the error.
 I just ran these by hand with telnet.  They include some calls to /sessions so that
I could verify whether or not the session was actually being created.

Reported by sam@silverstripe.com on 2012-01-19 01:59:10


- _Attachment: [standalone-webdriver-session.txt](https://storage.googleapis.com/google-code-attachments/selenium/issue-2091/comment-9/standalone-webdriver-session.txt)_

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

So, I downloaded the code and it looks like the problem is that request.getRequestDispatcher("/WEB-INF/views/sessionCapabilities.jsp")
returns null, which suggests that my standalone web-app isn't functioning correctly.

Could it be that I'm missing something when starting the selenium standalone server?
 I'm running it like this:

java -jar selenium-server-standalone-2.17.0.jar

 - Using the Java distro provided with OSX Lion.
 - selenium-server-standalone-2.17.0.jar is the file downloaded from code.google.com.

My understanding is that this is all that's needed for the standalone server (hence
the name "standalone" ;-) ) but perhaps this will help diagnose the issue...

Reported by sam@silverstripe.com on 2012-01-19 02:42:08

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I have fixed here: https://github.com/facebook/php-webdriver/pull/22

Reported by tszming on 2012-01-19 04:50:50

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

It's happening for me also with selenium-server-standalone-2.20 by starting a hub:

java -jar selenium-server-standalone-2.20.jar

and then a single node for chrome 18:

java -jar selenium-server-standalone-2.20.jar -role wd -hub http://xxxx:4444/grid/register
-browser -browserName=chrome,version=!8 -Dwebdriver.chrome.driver=/path/to/chromedriver_18.0.1022.0.exe

I'm requesting a new session by just sending a post request, without any adapter code
involved, to http://xxxxxx:4444/wd/hub/session with the following payload:

{"desiredCapabilities":{"browserName":"chrome"}}

and the response from the server (after seeing how a new chrome window spawns), is:

<html>
<head>
<title>Error 500 java.util.concurrent.ExecutionException: java.lang.NullPointerException</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2><pre>java.util.concurrent.ExecutionException: java.lang.NullPointerException</pre>
<p>RequestURI=/wd/hub/session/1333378712750</p>
<p><i><small><a href="http://jetty.mortbay.org">Powered by Jetty://</a></small></i></p>


Reported by davidst on 2012-04-02 15:19:06

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

As commented at 11, the fix requires sending the "Accept: application/json" header.
I have confirmed it with a simple http client.

But according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, if the server
requires any client to indicate that it accepts json as a valid reponse format, it
definitely does not look like something that should be handled with a 500 error, but
a 406.

Reported by davidst on 2012-04-03 11:01:04

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Comment 11 has been merged into PHP code maintained by Facebook. Closing issue

Reported by david.burns@theautomatedtester.co.uk on 2012-05-05 21:12:14

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

in my situation when i used javascript to execute during test with behat mink selenium
catch an error like :
*selenium  Curl error thrown for....   The requested URL returned error: 500 Internal
Server Error*
i found that the javascript usage will not return to the selenium standalone that it's
job is done or not .and then the server send another test row .
so 2 request conflict with each other so the error raised.
my solution was force system to wait for 500 millisecond .

Reported by hamed.nova on 2015-01-27 09:55:09

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:13:16

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 2, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant