I was running a series of unit tests using jBrowser and getting errors like
org.openqa.selenium.WebDriverException: java.lang.IllegalStateException: Could not launch browser. and various others such as JNI errors and NoClassDefFound for CookieStore. Very perplexing. In the end it was just a memory issue. I'd forgotten to close each instance of jBrowser when the test exited.
I needed to debug a maven build on a Vagrant VM running CentOS, this was because the build was passing fine on the Ubuntu host but tests were failing on the CentOS guest.
First I set up IntelliJ: Run > Edit Configurations... The only two parameters which had to be changed were the configuration name (pick any value) and entering the guest's IP in the host field.
Then I ran maven on the guest with:
mvn -Dmaven.surefire.debug test -pl path/to/project -am
Maven pauses the tests when it reaches them at which point I hit the debug button for the configuration I created. Breakpoints etc. then work normally.