When running a selenium test it fails with:
com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: sessionId should not be null; has this session been started yet?
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:73)
When inspecting the log file of the selenium server I noticed a stack trace:
21:08:32.588 INFO [11] org.openqa.selenium.server.SeleniumDriverResourceHandler - Command request: getNewBrowserSession[*iexplore, http://localhost:8280/tpm-selenium] on session null
21:08:32.588 INFO [11] org.openqa.selenium.server.BrowserSessionFactory - creating new remote session
21:08:33.804 WARN [11] org.mortbay.http.HttpConnection - POST /selenium-server/driver/ HTTP/1.1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1938)
at org.openqa.selenium.server.browserlaunchers.WindowsUtils$RegKeyValue.<init>(WindowsUtils.java:622)
at org.openqa.selenium.server.browserlaunchers.WindowsUtils.deleteRegistryValue(WindowsUtils.java:577)
at org.openqa.selenium.server.browserlaunchers.WindowsProxyManager.handleEvilPopupMgrBackup(WindowsProxyManager.java:106)
at org.openqa.selenium.server.browserlaunchers.WindowsProxyManager.init(WindowsProxyManager.java:81)
at org.openqa.selenium.server.browserlaunchers.WindowsProxyManager.<init>(WindowsProxyManager.java:65)
at org.openqa.selenium.server.browserlaunchers.InternetExplorerCustomProxyLauncher.<init>(InternetExplorerCustomProxyLauncher.java:48)
at org.openqa.selenium.server.browserlaunchers.InternetExplorerCustomProxyLauncher.<init>(InternetExplorerCustomProxyLauncher.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(BrowserLauncherFactory.java:124)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(BrowserLauncherFactory.java:81)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:307)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:113)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:78)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:653)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:410)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:388)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:135)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
21:08:33.804 DEBUG [11] org.mortbay.http.HttpConnection - RESPONSE:
HTTP/1.1 500 Internal Server Error
Date: Wed, 07 May 2008 19:08:32 GMT
Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.6.0_04
Connection: close
I think line number 106 of WindowsProxyManager shoul be changed to:
WindowsUtils.deleteRegistryValue(RegKey.POPUP_MGR.key);
This isn't minor! It stops the selenium server from starting. If some remote machine update thing has deleted the registry entry for the popup manager (which happened to my machine) then you can't start the selenium server. See http://clearspace.openqa.org/message/46309