title: Sonar-Runner job can't write to G:\.sonar_lock (looks like cache dir to me)
body: <p>We installed a new SonarQube 5.2 instance with Sonar-Runner 2.4 and MSSqlServer with the sonar.jdbc.url=jdbc:jtds:sqlserver:... driver.</p>
  
  <p>For some reason we can't identify where the .sonar_lock configuration is being written to by sonar-runner.bat analysis.  There seems to be a permission error there somewhere and it may be because the task is running under a "bamboo" service account user.  It could also be due to cached data somewhere (possibly) copied from a different server.  Not sure.  I can see where the lock is supposed to exist and we are trying to set
      -Dsonar.working.directory=${bamboo.build.working.directory}/.sonar   and
      -Dsonar_user_home=${bamboo.build.working.directory}/../.sonar (trying to write it to a common directory at runtime, but the error is still showing up on attempting to write to "G:\"  We don't want it to write to the root of the drive because there is bad juju relative to security policies on that location.  And we can't see where that is set anyway.</p>
  
  <p>Maven plugin jobs work fine, groovy plugin jobs work fine, this is just an issue using the sonar-runner.bat.  I checked that .bat file and did a hard code of the "set SONAR_RUNNER_HOME=%~dp0.." to a location that wasn't the G: drive. but that is still giving us the error in the same location. </p>
  
  <p>The error we are seeing is this: </p>
  
  <pre><code>build   04-Jan-2016 15:07:11    15:07:11.297 DEBUG - Publish global mode
  build   04-Jan-2016 15:07:11    15:07:11.843 DEBUG - cache:         C:\Users\XBBOSP000\.sonar\ws_cache\https%3A%2F%2Fsomewebsitesomewhere.net\global
  build   04-Jan-2016 15:07:11    15:07:11.906 INFO  - Load global repositories
  build   04-Jan-2016 15:07:11    15:07:11.937 DEBUG - Download: https://somewebsitesomewhere.net/batch/global (no proxy)
  build   04-Jan-2016 15:07:12    15:07:12.514 INFO  - Load global repositories (done) | time=592ms
  build   04-Jan-2016 15:07:12    15:07:12.842 WARN  - Property 'sonar.jdbc.url' is not supported any more. There is no more DB connection to the SQ database. It will be ignored.
  build   04-Jan-2016 15:07:12    15:07:12.873 INFO  - User cache: C:\Users\XBBOSP000\.sonar\cache
  build   04-Jan-2016 15:07:14    15:07:14.152 INFO  - Load plugins index
  build   04-Jan-2016 15:07:14    15:07:14.152 DEBUG - Download: https://somewebsitesomewhere.net/deploy/plugins/index.txt (no proxy)
  build   04-Jan-2016 15:07:14    15:07:14.214 INFO  - Load plugins index (done) | time=62ms
  build   04-Jan-2016 15:07:14    15:07:14.214 DEBUG - Load plugins
  build   04-Jan-2016 15:07:15    15:07:15.806 DEBUG - Load plugins (done) | time=1592ms
  build   04-Jan-2016 15:07:15    15:07:15.962 DEBUG - API compatibility mode is enabled on plugin JavaScript [javascript] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:15    15:07:15.962 DEBUG - API compatibility mode is enabled on plugin Findbugs [findbugs] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:15    15:07:15.977 DEBUG - API compatibility mode is enabled on plugin Groovy [groovy] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:15    15:07:15.993 DEBUG - API compatibility mode is enabled on plugin Web [web] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:15    15:07:15.993 DEBUG - API compatibility mode is enabled on plugin XML [xml] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:15    15:07:15.993 DEBUG - API compatibility mode is enabled on plugin Widget Lab [widgetlab] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.024 DEBUG - API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.024 DEBUG - API compatibility mode is enabled on plugin JIRA [jira] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.024 DEBUG - API compatibility mode is enabled on plugin Page Decoration [pagedecoration] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.040 DEBUG - API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.055 DEBUG - API compatibility mode is enabled on plugin PMD [pmd] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.071 DEBUG - API compatibility mode is enabled on plugin Java [java] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.071 DEBUG - API compatibility mode is enabled on plugin .NET [dotnet] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.086 DEBUG - API compatibility mode is enabled on plugin C# [csharp] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.118 DEBUG - API compatibility mode is enabled on plugin Crowd [crowd] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:16    15:07:16.118 DEBUG - API compatibility mode is enabled on plugin Cobertura [cobertura] (built with API lower than 5.2)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG - Plugins:
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * JavaScript 2.8 (javascript)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Findbugs 3.3 (findbugs)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Groovy 1.3 (groovy)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Web 2.4 (web)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * XML 1.3 (xml)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Widget Lab 1.8.1 (widgetlab)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Git 1.0 (scmgit)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * JIRA 1.2 (jira)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Page Decoration 1.0.1 (pagedecoration)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * SVN 1.2 (scmsvn)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * PMD 2.5 (pmd)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Java 3.7.1 (java)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * .NET 2.1 (dotnet)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * C# 4.3 (csharp)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Crowd 2.0 (crowd)
  build   04-Jan-2016 15:07:18    15:07:18.785 DEBUG -   * Cobertura 1.6.3 (cobertura)
  build   04-Jan-2016 15:07:19    15:07:19.659 INFO  - Process project properties
  build   04-Jan-2016 15:07:19    15:07:19.659 DEBUG - Process project properties (done) | time=0ms
  build   04-Jan-2016 15:07:20    INFO: ------------------------------------------------------------------------
  build   04-Jan-2016 15:07:20    INFO: EXECUTION FAILURE
  build   04-Jan-2016 15:07:20    INFO: ------------------------------------------------------------------------
  build   04-Jan-2016 15:07:20    Total time: 14.639s
  build   04-Jan-2016 15:07:20    Final Memory: 8M/76M
  build   04-Jan-2016 15:07:20    INFO: ------------------------------------------------------------------------
  error   04-Jan-2016 15:07:20    ERROR: Error during Sonar runner execution
  error   04-Jan-2016 15:07:20    org.sonar.runner.impl.RunnerException: Unable to execute Sonar
  error   04-Jan-2016 15:07:20        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
  error   04-Jan-2016 15:07:20        at java.security.AccessController.doPrivileged(Native Method)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.api.Runner.execute(Runner.java:100)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.Main.executeTask(Main.java:70)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.Main.execute(Main.java:59)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.Main.main(Main.java:53)
  error   04-Jan-2016 15:07:20    Caused by: java.lang.IllegalStateException: Failed to create lock in G:\.sonar_lock
  error   04-Jan-2016 15:07:20        at org.sonar.home.cache.DirectoryLock.tryLock(DirectoryLock.java:67)
  error   04-Jan-2016 15:07:20        at org.sonar.batch.scan.ProjectLock.tryLock(ProjectLock.java:43)
  error   04-Jan-2016 15:07:20        at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:118)
  error   04-Jan-2016 15:07:20        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:98)
  error   04-Jan-2016 15:07:20        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
  error   04-Jan-2016 15:07:20        at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
  error   04-Jan-2016 15:07:20        at     org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
  error   04-Jan-2016 15:07:20        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
  error   04-Jan-2016 15:07:20        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  error   04-Jan-2016 15:07:20        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  error   04-Jan-2016 15:07:20        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  error   04-Jan-2016 15:07:20        at java.lang.reflect.Method.invoke(Method.java:606)
  error   04-Jan-2016 15:07:20        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
  error   04-Jan-2016 15:07:20        ... 9 more
  error   04-Jan-2016 15:07:20    Caused by: java.io.FileNotFoundException: G:\.sonar_lock (Access is denied)
  error   04-Jan-2016 15:07:20        at java.io.RandomAccessFile.open(Native Method)
  error   04-Jan-2016 15:07:20        at java.io.RandomAccessFile.&lt;init&gt;(RandomAccessFile.java:241)
  error   04-Jan-2016 15:07:20        at org.sonar.home.cache.DirectoryLock.tryLock(DirectoryLock.java:61)
  error   04-Jan-2016 15:07:20        ... 22 more
  </code></pre>