Both new and old are Sonarqube 5.6 with Oracle. The old database is
Oracle 11g and the new will be Oracle 12c, but I am using the Oracle
Express 11g and another local Sonarqube 5.6 installation in order to test the procedure.
I proceed as follows:
(1) Export old database with SQL Developer as DDL (insert format)
(2) Make some small changes to resulting sql:
   - Tablespace name is hard-coded and different in target database so had to be adapted
   - SQL Clause "SEGMENT CREATION DEFERRED" not supported in target database, so I simply deleted it
(3) Import sql to new target database (execute in sqlplus)
(4) Start new Sonarqube instance connecting to new database
After this unfortunately the Sonarqube server ends and in the logs I see the error/exception:
Exception sending context initialized event to listener
instance of class
org.sonar.server.platform.PlatformServletContextListener
(full text below).
Further tests:
If I start the new Sonarqube instance against the new database with no imported data
fresh tables are created and all is well. After doing that I can also export the new database,
drop and recreate the new sonarqube database user, and re-import the data from the new environment,
also works fine.
That is to say the new installation in stand-alone mode works fine, the export/import also works
fine (at least with minimal data and exported from the same environment / database).
The problem therefore seems to be caused by something in the data I am importing from the old
Sonarqube installation.
I have also tried after the import rebuilding all indexes (no change), and deleting all rows
from all tables (sonarqube then tries to create new tables and runs into an error because
table projects alreads exists).
One thing that does occur to me is that the old installation has many plugins. I have tried
to get the new installation to the same state but it is not totally identical, there are a few
version differences and the old installation had some licenced plugins (Swift and Objective C)
that I do not have for my local test installation. There are also a few error messages in the log
to that effect, but these don't seem to be the critical problem.
2017.01.21 00:07:53 ERROR web[cpp] No license for cpp
2017.01.21 00:07:53 ERROR web[objc] No license for objc
I have also tried deleting the logs, data, temp directories in Sonarqube before starting the
new server against the new database.
I have of course searched for this error message but it seems to mostly occur when migrating
from one Sonar version to another which is not the case here.
Does anyone have any thoughts?
Should this procedure theoretically work or have I missed something?
Many thanks for any ideas!
2017.01.21 00:08:29 INFO web[o.s.s.n.NotificationService] Notification service stopped
2017.01.21 00:08:29 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at com.google.common.base.Throwables.propagate(Throwables.java:160) ~[guava-17.0.jar:na]
at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:82) ~[sonar-server-5.6.jar:na]
at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:88) ~[sonar-server-5.6.jar:na]
at org.sonar.server.es.IndexerStartupTask.execute(IndexerStartupTask.java:71) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:81) ~[sonar-server-5.6.jar:na]
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:44) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:77) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:201) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:114) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:99) ~[sonar-server-5.6.jar:na]
at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:44) ~[sonar-server-5.6.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.30.jar:8.0.30]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_65]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_65]
at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:135) ~[guava-17.0.jar:na]
at org.sonar.server.es.BaseIndexer.index(BaseIndexer.java:80) ~[sonar-server-5.6.jar:na]
... 18 common frames omitted
Caused by: java.lang.NullPointerException: null
at java.io.FilterInputStream.close(FilterInputStream.java:181) ~[na:1.8.0_65]
at org.apache.commons.io.IOUtils.closeQuietly(IOUtils.java:303) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.closeQuietly(IOUtils.java:246) ~[commons-io-2.4.jar:2.4]
at org.sonar.db.source.FileSourceDto.decodeTestData(FileSourceDto.java:169) ~[sonar-db-5.6.jar:na]
at org.sonar.server.test.index.TestResultSetIterator.read(TestResultSetIterator.java:79) ~[sonar-server-5.6.jar:na]
at org.sonar.server.test.index.TestResultSetIterator.read(TestResultSetIterator.java:60) ~[sonar-server-5.6.jar:na]
at org.sonar.db.ResultSetIterator.next(ResultSetIterator.java:82) ~[sonar-db-5.6.jar:na]
at org.sonar.server.test.index.TestIndexer.doIndex(TestIndexer.java:93) ~[sonar-server-5.6.jar:na]
at org.sonar.server.test.index.TestIndexer.doIndex(TestIndexer.java:80) ~[sonar-server-5.6.jar:na]
at org.sonar.server.test.index.TestIndexer.doIndex(TestIndexer.java:70) ~[sonar-server-5.6.jar:na]
at org.sonar.server.es.BaseIndexer$2.index(BaseIndexer.java:91) ~[sonar-server-5.6.jar:na]
at org.sonar.server.es.BaseIndexer$1.run(BaseIndexer.java:73) ~[sonar-server-5.6.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_65]
... 4 common frames omitted
2017.01.21 00:08:29 ERROR web[o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file
2017.01.21 00:08:29 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors
2017.01.21 00:08:29 WARN web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:170)
java.net.SocketInputStream.read(SocketInputStream.java:141)
java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
java.io.BufferedInputStream.read(BufferedInputStream.java:345)
com.sun.jndi.ldap.Connection.run(Connection.java:860)
java.lang.Thread.run(Thread.java:745)
2017.01.21 00:08:29 WARN web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Progress[BulkIndexer[tests]]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
2017.01.21 00:08:29 INFO web[o.a.c.h.Http11NioProtocol] Starting ProtocolHandler ["http-nio-0.0.0.0-9000"]
2017.01.21 00:08:29 INFO web[o.s.s.a.TomcatAccessLog] Web server is started
2017.01.21 00:08:29 INFO web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2017.01.21 00:08:29 WARN web[o.s.p.ProcessEntryPoint] Fail to start web
java.lang.IllegalStateException: Webapp did not start
at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.6.jar:na]
at org.sonar.server.app.WebServer.isUp(WebServer.java:47) [sonar-server-5.6.jar:na]
at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.6.jar:na]
at org.sonar.server.app.WebServer.main(WebServer.java:68) [sonar-server-5.6.jar:na]
2017.01.21 00:08:29 INFO web[o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-0.0.0.0-9000"]
2017.01.21 00:08:30 INFO web[o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-0.0.0.0-9000"]
2017.01.21 00:08:30 INFO web[o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-0.0.0.0-9000"]
2017.01.21 00:08:30 INFO web[o.s.s.a.TomcatAccessLog] Web server is stopped
2017.01.21 00:08:30 INFO app[o.s.p.m.Monitor] Process[es] is stopping
2017.01.21 00:08:31 INFO es[o.s.p.StopWatcher] Stopping process
2017.01.21 00:08:31 INFO es[o.elasticsearch.node] [sonar-1484953654097] stopping ...