How to configure sonarqube with oracle database

configuration

(Kiran) #1

I’m using SonarQube 6.7.5 and sonar scanner 3.2.0, by default h2 database is used. When I try to integrate with oracle database by giving in the url, database name and password, still being connected to h2.

sonar.jdbc.username:sonaruser
sonar.jdbc.password:XXXXXXXXXX
sonar.jdbc.url: jdbc:oracle:thin:@localhost:1522:SONARDB
sonar.jdbc.driverClassname: oracle.jdbc.OracleDriver
sonar.jdbc.dialect: oracle
sonar.jdbc.validationQuery: select 1 from dual

Property ‘sonar.jdbc.username’ is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database

Can some one suggest how to set it up with oracle database?


(Colin Mueller) #2

Kiran,

Those are some interesting properties you’re setting. I don’t believe they are all in the default sonar.properties? What documentation are you following?

I’d reccomend the Installing the Database section of these setup docs. You should only need the url, username, and password. Make sure you’re restarting the server after changing the configuration.

Colin


(Kiran) #3

I just followed the steps mentioned in there
sonar.jdbc.url=jdbc:oracle:thin:@localhost:1522/SONARDB
sonar.jdbc.username=sonaruser
sonar.jdbc.password=XXXXXXX

These are the only settings included in my sonar-scanner.properties file.
Still h2 database is only being used. I restarted the sonar server but still h2 is only being used not sure how to handle this.


(Colin Mueller) #4

Kiran,

Make sure you are editing the sonar.properties file in your SONARQUBE_HOME/conf/ directory. These settings aren’t related to the scanner.

Colin


(Kiran) #5

Thanks for confirming the correct file. I moved the settings to sonar.properties and I get the following message when I try to start the server.

C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\bin\windows-x86-64>StartSonar
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    |
jvm 1    | 2018.09.20 22:11:21 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\temp
jvm 1    | 2018.09.20 22:11:21 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1    | 2018.09.20 22:11:21 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\elasticsearch]: C:\Program Files\Java\jre1.8.0_181\bin\java -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFr
action=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.s
hutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -Xms512m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\elasticsearch -cp lib/* org.elasticsearch.bootstrap.Elasticsearch -Epath.conf=C:\SonarQube\Downl
oads\SonarQube\sonarqube-6.7.5\temp\conf\es
jvm 1    | 2018.09.20 22:11:21 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1    | 2018.09.20 22:11:22 INFO  app[][o.e.p.PluginsService] no modules loaded
jvm 1    | 2018.09.20 22:11:22 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
jvm 1    | 2018.09.20 22:11:40 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1    | 2018.09.20 22:11:40 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5]: C:\Program Files\Java\jre1.8.0_181\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=
C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*;./lib/server/*;C:\SonarQube\Downloads\SonarQube\sonarqube-6.7.5\extensions\jdbc-driver\oracle\ojdbc8.jar org.sonar.server.app.WebServer C:\SonarQube\Downloads\SonarQube\sonarqub
e-6.7.5\temp\sq-process3736753442868766462properties
jvm 1    | 2018.09.20 22:11:48 INFO  app[][o.s.a.SchedulerImpl] Process [web] is stopped
jvm 1    | 2018.09.20 22:11:48 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
jvm 1    | 2018.09.20 22:11:48 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
wrapper  | <-- Wrapper Stopped

Appreciate your instant replies.


(Colin Mueller) #6

Kiran,

This is progress! Check the /logs/ folder of your SonarQube install directory. Anything interesting? Check each file if there is more than one.

Colin


(Kiran) #7

Yes there are two log files for web
web.log and web.2018-09-19.log

Any suggestions to proceed forward with?


(Colin Mueller) #8

Quite likely you should open them and see what they have to say. Look for WARN or ERROR messages. Checkout the es.log, sonar.log, and ce.log files also and get familiar with them. This is the first step in troubleshooting a SonarQube server.

Colin


(Kiran) #9

Yes I checked all the log files and fixed the user credentials error message listed in the logs.
Was able to successfully bring up the server. Now the issue is I was able to successfully run the sonar-scanner with h2 database and a report was generated. It used to take close to 1.5 hrs on h2 for the report report to be generated. Now with oracle db when I run the sonar-scanner it runs for 2 minutes and when I refresh the projects on the server, I see everything as 0. I don’t see any report.

org.elasticsearch.action.FailedNodeException: Failed node [ellbU6C5R22Q74-7dDyamg]
	at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction.onFailure(TransportNodesAction.java:239) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction.access$200(TransportNodesAction.java:153) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction$1.handleException(TransportNodesAction.java:211) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1067) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1171) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1149) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService$7.onFailure(TransportService.java:655) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onFailure(ThreadContext.java:623) [elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39) [elasticsearch-5.6.3.jar:5.6.3]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_181]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: org.elasticsearch.transport.RemoteTransportException: [sonarqube][127.0.0.1:9001][internal:gateway/local/started_shards[n]]
Caused by: org.elasticsearch.ElasticsearchException: failed to load started shards
	at org.elasticsearch.gateway.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:171) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.gateway.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:61) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.nodes.TransportNodesAction.nodeOperation(TransportNodesAction.java:140) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.nodes.TransportNodesAction$NodeTransportHandler.messageReceived(TransportNodesAction.java:262) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.nodes.TransportNodesAction$NodeTransportHandler.messageReceived(TransportNodesAction.java:258) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.6.3.jar:5.6.3]
	... 3 more

(Alexandre Frigout) #10

Hi Kiran,

You should stop your SQ instance, remove the content of the SONARQUBE_HOME/data/es5 directory and restart your instance.
This will refresh your elastic search index.

Greetings,
Alexandre.


(Kiran) #11

Hi Alexandre,

Thank you for your response.
I deleted the content of SONARQUBE_HOME/data/es5 directory and restarted the server, when I run the scanner still it shows the same error.

org.elasticsearch.action.FailedNodeException: Failed node [KKKJzKsWQUC2NtYCw2XXxA]
at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction.onFailure(TransportNodesAction.java:239) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction.access$200(TransportNodesAction.java:153) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.action.support.nodes.TransportNodesAction$AsyncAction$1.handleException(TransportNodesAction.java:211) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1067) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1171) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1149) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.TransportService$7.onFailure(TransportService.java:655) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onFailure(ThreadContext.java:623) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39) [elasticsearch-5.6.3.jar:5.6.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_181]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: org.elasticsearch.transport.RemoteTransportException: [sonarqube][127.0.0.1:9001][internal:gateway/local/started_shards[n]]
Caused by: org.elasticsearch.ElasticsearchException: failed to load started shards
at org.elasticsearch.gateway.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:171) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.gateway.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:61) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.action.support.nodes.TransportNodesAction.nodeOperation(TransportNodesAction.java:140) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.action.support.nodes.TransportNodesAction$NodeTransportHandler.messageReceived(TransportNodesAction.java:262) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.action.support.nodes.TransportNodesAction$NodeTransportHandler.messageReceived(TransportNodesAction.java:258) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.6.3.jar:5.6.3]
… 3 more