Encountering exception in org.sonarqube(2.0.1) gradle plugin


(Prashant Mahajan) #1

We have written a small precheck script that checks if sonar db if up and running or not ?
Snippet of code

public boolean isUp(int maxRetry, int sleepTime){
def dbUrl = "jdbc:oracle:thin:@" + this.host + ":" + this.port + "/" + this.sid
def driver = new OracleDriver() as java.sql.Driver
def exception 
boolean isConnectionSuccess = false
def conn
for(int i = 0; i < maxRetry; i++ ){
  try {
    LOGGER.log( Level.INFO, "Attepmt number ${i + 1} for DB: ${dbUrl}" );
     conn = driver.connect(dbUrl, [user: this.user, password: this.password] as Properties)
     if( conn != null ){
       isConnectionSuccess = true
       break
     }
  }
  catch(SQLException ex) {
    LOGGER.log( Level.WARNING, "Connection to DB failed with exception: ${ex.toString()}" );
    sleep(sleepTime)
  }finally {
if( conn != null ){
        conn.close();
}
    }
}
return isConnectionSuccess

Though I am getting desired print msg here afterwards i.e DB is up but now when the sonarqube run’s in analysis mode after this it fails with below error :

00:04:31.555 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Extract sonar-scanner-api-batch in temp...
00:04:31.564 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Get bootstrap index...
00:04:31.564 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Download: http://sonarserver.com:9000/sonar/batch_bootstrap/index
00:04:31.648 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Get bootstrap completed
00:04:31.650 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Create isolated classloader...
00:04:31.658 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Start temp cleaning...
00:04:31.673 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Temp cleaning done
00:04:31.673 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution getVersion
00:04:31.688 [INFO] [org.sonarqube.gradle.SonarQubeTask] Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
00:04:31.689 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Work directory: /gitpath/build/sonar
00:04:31.689 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution getVersion
00:04:31.689 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution executeOldVersion
00:04:32.068 [QUIET] [system.out] 00:04:32.065 INFO  - Load batch settings
00:04:32.083 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@6785c78b7 pairs: {GET /sonar/batch_bootstrap/properties?dryRun=false HTTP/1.1: null}{Accept-Encoding: gzip}{Authorization: Basic ZW1hYXM6ZW1hYXM=}{User-Agent: Sonar Gradle/1.12}{Host: sonarserver.com:9000}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
00:04:32.111 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@7fefabc511 pairs: {null: HTTP/1.1 200 OK}{Server: Apache-Coyote/1.1}{Set-Cookie: JSESSIONID=211B1A4FD48C3389A3F342ACBEC5E943; Path=/sonar/; HttpOnly}{X-Runtime: 19}{ETag: "883f57d9578d47d46788e17c18e523d5"}{Cache-Control: private, max-age=0, must-revalidate}{Content-Type: application/json;charset=utf-8}{Transfer-Encoding: chunked}{Content-Encoding: gzip}{Vary: Accept-Encoding}{Date: Mon, 21 Aug 2017 07:04:32 GMT}
00:04:32.174 [QUIET] [system.out] 00:04:32.174 INFO  - User cache: /gitpath/cache
00:04:32.183 [QUIET] [system.out] 00:04:32.183 INFO  - Install plugins
00:04:32.184 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@39ae16937 pairs: {GET /sonar/deploy/plugins/index.txt HTTP/1.1: null}{Accept-Encoding: gzip}{Authorization: Basic ZW1hYXM6ZW1hYXM=}{User-Agent: Sonar Gradle/1.12}{Host: sonarserver.com:9000}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
00:04:32.185 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@544c2a7a10 pairs: {null: HTTP/1.1 200 OK}{Server: Apache-Coyote/1.1}{Accept-Ranges: bytes}{ETag: W/"2286-1503283124000"}{Last-Modified: Mon, 21 Aug 2017 02:38:44 GMT}{Content-Type: text/plain}{Transfer-Encoding: chunked}{Content-Encoding: gzip}{Vary: Accept-Encoding}{Date: Mon, 21 Aug 2017 07:04:32 GMT}
00:04:32.264 [QUIET] [system.out] 00:04:32.264 INFO  - Install JDBC driver
00:04:32.265 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@7f69af57 pairs: {GET /sonar/deploy/jdbc-driver.txt HTTP/1.1: null}{Accept-Encoding: gzip}{Authorization: Basic ZW1hYXM6ZW1hYXM=}{User-Agent: Sonar Gradle/1.12}{Host: sonarserver.com:9000}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
00:04:32.266 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@4f374ee88 pairs: {null: HTTP/1.1 200 OK}{Server: Apache-Coyote/1.1}{Accept-Ranges: bytes}{ETag: W/"43-1503283123000"}{Last-Modified: Mon, 21 Aug 2017 02:38:43 GMT}{Content-Type: text/plain}{Content-Length: 43}{Date: Mon, 21 Aug 2017 07:04:32 GMT}
00:04:32.272 [QUIET] [system.out] 00:04:32.272 INFO  - Create JDBC datasource for jdbc:oracle:thin:@sonarserver.com:1521:sonarq
00:04:32.285 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':sonarqube'
00:04:32.285 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :sonarqube FAILED
00:04:32.286 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :sonarqube (Thread[main,5,main]) completed. Took 1.468 secs.
00:04:32.286 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 2.978 secs, idle: 0.0 secs
00:04:32.292 [ERROR] [org.gradle.BuildExceptionReporter] 
00:04:32.293 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
00:04:32.293 [ERROR] [org.gradle.BuildExceptionReporter] 
00:04:32.293 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
00:04:32.294 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':sonarqube'.
00:04:32.294 [ERROR] [org.gradle.BuildExceptionReporter] > Fail to connect to database
00:04:32.296 [ERROR] [org.gradle.BuildExceptionReporter] 
00:04:32.296 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
00:04:32.297 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
00:04:32.297 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
00:04:32.297 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
00:04:32.298 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
00:04:32.299 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
00:04:32.299 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
00:04:32.299 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
00:04:32.299 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
00:04:32.299 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
00:04:32.300 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
00:04:32.301 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
00:04:32.302 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.Main.doAction(Main.java:46)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.Main.main(Main.java:37)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
00:04:32.303 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalStateException: Fail to connect to database
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:80)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
00:04:32.304 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
00:04:32.305 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.executeOldVersion(BatchIsolatedLauncher.java:70)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at com.sun.proxy.$Proxy41.executeOldVersion(Unknown Source)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:245)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:84)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
00:04:32.306 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
00:04:32.307 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] 	... 43 more
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
00:04:32.308 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultDatabase.java:125)
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:75)
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 	... 70 more
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.SecurityException: sealing violation: package oracle.jdbc.driver is sealed
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 	... 75 more
00:04:32.309 [ERROR] [org.gradle.BuildExceptionReporter] 
00:04:32.309 [LIFECYCLE] [org.gradle.BuildResultLogger] 
00:04:32.310 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
00:04:32.310 [LIFECYCLE] [org.gradle.BuildResultLogger] 
00:04:32.310 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 56.62 secs
00:04:32.310 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
00:04:32.311 [INFO] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopped 0 compiler daemon(s).

In case I don’t call the precheck script org.sonarqube plugin works perfectly fine.Please guide what I am missing in the above precheck script that is breaking my flow.


(Tim Yates) #2

Hiya, the root cause is:

Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'

Do you have the driver on your buildSrc classpath?


(Prashant Mahajan) #3

Hi Tim,
My build.gradle contains below snippet.I hope that should be suffice.
dependencies {
compile gradleApi()
compile localGroovy()
compile group: ‘com.oracle.jdbc’, name: ‘ojdbc6’, version: ‘11.2.0.2.1’
}
What I am not able to understand is why sonarqube is complaining about this security exception :
package oracle.jdbc.driver is sealed
Also to add, in case I run above code with sonarRunner everything works fine.The problem comes only when I move to sonarqube.
Please guide.Appreciate your Help…!!


(Tim Yates) #4

Can you come up with a simple failing example, or a link to your project that I can see and build?

The Sealed exception means you’ve the oracle drivers loaded twice on the classpath I believe


(Prashant Mahajan) #5

Hi Tim,
It seems in my case gradle cache and sonar cache both are downloading and adding the ojdbc6.jar in classpath thus resulting in the above error.

Got a page talking about same problem :

Is there a way to come out of this deadlock ?


(Tim Yates) #6

Can you elaborate why you think the gradle cache is loading the oracle driver jar?

If this relies on the sonar plugin being installed, can you just remove the line

compile group: 'com.oracle.jdbc', name: 'ojdbc6', version: '11.2.0.2.1'

from your script?


(uklance) #7

I’ve seen various hacks for executing sql as part of the build, most involve casting the buildscript classloader to URLClassloader and adding an extra jar to it. Pretty nasty

If it were me, I’d create a custom classloader in a task which loads the driver without polluting the buildscript classloader. The classloader would be gc’d after task execution

Here’s a little proof of concept


(Prashant Mahajan) #8

Thank You Lance for guiding on this.As of now, have commented the code calling the precheck script.Will try your proof of concept in near future to come out of this issue.


(Prashant Mahajan) #9

Hi Tim,
Had tried commenting the suggested line from build.gradle but this also results in failure only.No luck in that direction.As of now, have commented the code calling the precheck script.Thanks for guiding me on this.