Step 1: Download Sonar from the Sonar download website.
Step 2: Unzip the .zip file and move the entire 'sonar-3.0' directory to 'C:\Program Files'.
Step 3: Double-click C:\Program Files\sonar-3.0\bin\windows-x86-64\StartSonar.bat to start Sonar. If your machine is 32-bit, run C:\Program Files\sonar-3.0\bin\windows-x86-32\StartSonar.bat instead.
Step 4: Verify it's running. Open up a browser and go to: http://localhost:9000/. You should see the following...
Step 5: Setup Sonar to start as a Windows Service. Double-click C:\Program Files\sonar-3.0\bin\windows-x86-64\InstallNTService.bat. If your machine is 32-bit, run C:\Program Files\sonar-3.0\bin\windows-x86-32\InstallNTService.bat instead.
Step 6: Restart the computer.
Step 7: Verify again that it's running. The Sonar Windows service should start Sonar when the machine boots up. Open up a browser and go to: http://localhost:9000/. For administration features, the Sonar default login/password is admin/admin.
One Small Issue
After restarting the computer and checking if Sonar was running, Sonar was not running. After some digging, I found that you can look in C:\Program Files\sonar-3.0\logs\sonar.log to debug Sonar. The following log messages hinted at the problem:INFO | jvm 1 | 2012/05/02 12:55:26 | WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: Unable to create file in temporary directory, please check existence of it and permissions: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\
INFO | jvm 1 | 2012/05/02 12:55:26 | java.lang.IllegalStateException: Unable to create file in temporary directory, please check existence of it and permissions: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\
INFO | jvm 1 | 2012/05/02 12:55:26 | at org.sonar.application.StartServer.canCreateTemporaryFiles(StartServer.java:60)
INFO | jvm 1 | 2012/05/02 12:55:26 | java.lang.IllegalStateException: Unable to create file in temporary directory, please check existence of it and permissions: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\
INFO | jvm 1 | 2012/05/02 12:55:26 | at org.sonar.application.StartServer.canCreateTemporaryFiles(StartServer.java:60)
Apparently, Sonar is trying to write to a temp file and Windows is not letting it. After all failed attemps to create the Temp folder manually and remove the write protection, I ended up solving the issue by manually configuring the Windows Service. The Sonar Windows Service's "user" was LocalSystem by default. I had to switch the service over to run under a regular user, and that fixed the issue.
Piece of Cake!!!
Relevant Links
Sonar on Wikipediasonarsource.org
Thanks. This saved me big time!
ReplyDeleteThanks for the hint with windows service and temp dir, you're my todays time saver! :D
ReplyDeleteThanks. This hint helped me. But I also had to set the sonar directory rights to this user.
ReplyDeleteThanks!!. Fixed my issue.
ReplyDeleteVery clear description - most helpful. I love the use of inset screenshots for clarity.
ReplyDeleteThis is sooooo much more useful than the Sonar installation page.
I have post a blog to help people to Install and configure Sonar on Windows 7 for C# project in 10 minutes... check it out. It talks about running it as service as well.
ReplyDeletehttp://sharedtolearn.blogspot.ca/2012/10/install-and-configure-sonar-on-windows.html
I was able to designate Network Service, clear the password fields and hit apply. started up rather smartly!
ReplyDeleteThanks, good info. BTW, I was able to use Network Service as well. clear the PW fields and hit apply. good to go.
ReplyDeleteWell, I discovered that the Temp folder didn't exist. Created it and the issue went away allowing the service account to work without using a user account.
ReplyDeleteYou could also define where you want the temp folder to be e.g. -Djava.io.tmpdir=C:/Temp/. See here for more details.
ReplyDeletethis was a blessing to know, thanks buddy
ReplyDeleteReally helpful :)
ReplyDeleteThank you!! You saved me a lot of time with your advice!
ReplyDelete+1
ReplyDeleteThanks for the Hint. Could figure out the Issue.
ReplyDeleteThe 'Temp' folder has to created at
C:\Windows\SysWOW64\config\systemprofile\AppData\Local
clearing sonar server temp folder fixed my problem
ReplyDeleteC:\sonarqube\temp