"Can not attach to current VM" error message on trying to execute tests in parallel

4,030 views
Skip to first unread message

shailender g

unread,
Mar 4, 2019, 5:22:16 PM3/4/19
to testng...@googlegroups.com
Trying to migrate our scripts to win10 and openjdk 11.0.2 from win7 and oraclejdk8
Steps to reproduce 
1. Set up selenium grid successfully

Below is a log from it:
Hub
14:37:43.311 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.0, revision: 2ecb7d9a
14:37:43.359 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4444
2019-03-04 14:37:43.772:INFO::main: Logging initialized @660ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:37:44.054 INFO [Hub.start] - Selenium Grid hub is up and running
14:37:44.054 INFO [Hub.start] - Nodes should register to http://172.30.4.66:4444/grid/register/
14:37:44.054 INFO [Hub.start] - Clients should connect to http://172.30.4.66:4444/wd/hub
15:18:04.023 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.4.66:4628
16:49:58.415 INFO [DefaultRemoteProxy.onEvent] - Marking the node http://172.30.4.66:4628 as down: cannot reach the node for 2 tries
16:50:58.734 INFO [DefaultRemoteProxy.onEvent] - Unregistering the node http://172.30.4.66:4628 because it's been down for 60320 milliseconds
16:50:58.734 WARN [DefaultGridRegistry.removeIfPresent] - Cleaning up stale test sessions on the unregistered node http://172.30.4.66:4628
16:54:03.935 INFO [DefaultGridRegistry.add] - Registered a node http://172.30.4.66:5437


Node 
16:54:02.976 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.0, revision: 2ecb7d9a
16:54:03.049 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5437
2019-03-04 16:54:03.356:INFO::main: Logging initialized @608ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:54:03.529 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
16:54:03.575 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5437
16:54:03.575 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
16:54:03.685 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:54:03.841 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
16:54:03.935 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
16:56:09.667 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "chrome.binary": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
  "goog:chromeOptions": {
    "args": [
    ],
    "extensions": [
    ]
  },
  "version": ""
}
16:56:09.667 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:56:14.740 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "chrome.binary": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
  "goog:chromeOptions": {
    "args": [
    ],
    "extensions": [
    ]
  },
  "version": ""
}
16:56:14.740 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
17:06:46.410 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome"
}
17:06:46.411 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
17:07:09.729 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "internet explorer"
}
17:07:09.729 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.ie.InternetExplorerDriverService)
17:07:18.887 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome"
}
17:07:18.888 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)


2. Create a new testng, maven, selenium project with Sample test ng class as below:

public class GridTest {


  @Test
  public void test() throws MalformedURLException {
    WebDriver driver;
    
    System.setProperty("webdriver.chrome.driver", "C:\\Users\\<username>\\.m2\\repository\\webdriver\\chromedriver\\win32\\2.46\\chromedriver.exe");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    ChromeOptions options = new ChromeOptions();
    capabilities.setCapability("chrome.binary", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);

    driver= new RemoteWebDriver(new URL("http://localhost:5437/wd/hub"), capabilities);
    
    driver.get("https://www.google.com");
    driver.quit();
   
  }
  

}

3. Sample testng xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="sampleparallel" parallel="tests" thread-count="2">
 
 <test name="testngTest1">
 <classes>
 <class name="io.github.bonigarcia.wdm.test.GridTest" />
 </classes>
 </test> 
 
 <test name="testngTest2">
 <classes>
 <class name="io.github.bonigarcia.wdm.test.GridTest" />
 </classes>
 </test> 

</suite>

4. When i run above suite, I get below error :

[RemoteTestNG] detected TestNG version 6.14.3
java.lang.RuntimeException: java.io.IOException: Can not attach to current VM
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:152)
at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:60)
at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:156)
at mockit.integration.testng.TestNGRunnerDecorator.onExecutionStart(TestNGRunnerDecorator.java:348)
at org.testng.TestNG.runExecutionListeners(TestNG.java:1061)
at org.testng.TestNG.run(TestNG.java:1012)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.io.IOException: Can not attach to current VM
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:75)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:48)
at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:69)
at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:146)
... 8 more

If any of you have encountered above and were able to resolve, please help!

Environment: 
OS- Win 10
JDK- Openjdk 11.0.2
 <selenium-java.version>3.141.59</selenium-java.version>
testng- 6.14.3

Thanks
Shailender

⇜Krishnan Mahadevan⇝

unread,
Mar 4, 2019, 8:39:23 PM3/4/19
to testng...@googlegroups.com
TestNG has not yet officially been vetted out against JDK11. 

From your stack trace it looks to me like you are seeing this when running tests from within eclipse. 

This Stackoverflow post will explain what is going on here. 

You need to set a JVM argument that is mentioned in the above post to restore the old behaviour ( JDK behavior was changed in 9 )



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.com/

shailender g

unread,
Mar 5, 2019, 8:35:48 AM3/5/19
to testng...@googlegroups.com
What is the maximum version of jdk against which testng is tested?

⇜Krishnan Mahadevan⇝

unread,
Mar 5, 2019, 9:44:54 AM3/5/19
to testng...@googlegroups.com
I believe we are currently building the code using jdk8 and 9. 

shailender g

unread,
Mar 5, 2019, 10:42:22 AM3/5/19
to testng...@googlegroups.com
Which jdk? Oracle / open jdk?

⇜Krishnan Mahadevan⇝

unread,
Mar 5, 2019, 10:54:14 AM3/5/19
to testng...@googlegroups.com
Oracle JDK 8 and 9

shailender g

unread,
Mar 5, 2019, 1:19:45 PM3/5/19
to testng...@googlegroups.com
Thanks Krishnan! I did set the jdk vm argument but it still did not fix it! I now get below error message:

org.openqa.selenium.WebDriverException: Unable to parse remote response: 
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:115)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at io.github.bonigarcia.wdm.test.GridTest.test(GridTest.java:26)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: END. Last 0 characters read: 
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'CREDMDPCSGAN', ip: '172.30.4.66', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.json.JsonInput.expect(JsonInput.java:290)
at org.openqa.selenium.json.JsonInput.beginObject(JsonInput.java:220)
at org.openqa.selenium.json.MapCoercer.lambda$apply$1(MapCoercer.java:64)
at org.openqa.selenium.json.JsonTypeCoercer.lambda$null$6(JsonTypeCoercer.java:145)
at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:126)
at org.openqa.selenium.json.Json.toType(Json.java:69)
at org.openqa.selenium.json.Json.toType(Json.java:55)
at org.openqa.selenium.json.Json.toType(Json.java:50)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:112)
... 11 more

Although selenium \ testng does not explicitly say they do not support latest jdk 11+, I begin to doubt if it makes sense just to downgrade my openjdk version to 8/9 to be safe. If they do support and if I am doing something wrong I would love to learn where I am going wrong.

shailender g

unread,
Mar 5, 2019, 2:20:27 PM3/5/19
to testng...@googlegroups.com
Ignore above email Krishnan! It suddenly started working with 0 changes to scripts. Weird! 
Reply all
Reply to author
Forward
0 new messages