Gerrit 2.9.1 on Tomcat 8 (mirror setup) guiceFilter error on startup (due to NPE)

364 views
Skip to first unread message

Kenny Ho

unread,
Nov 19, 2014, 2:48:36 PM11/19/14
to repo-d...@googlegroups.com
Hi,

I am trying to configure Gerrit 2.9.1 mirror (container.slave=true) on top of Tomcat 8 but there are error when I tried doing ./bin/daemon.sh start.  I am using PostgreSQL.  I have the connector in the <tomcat>/lib directory and I also have the Resource tag in the conf/context.xml (and I also commented out the database config in gerrit.config).

<Resource name="jdbc/ReviewDb" auth="Container"
              type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
              url="jdbc:postgresql://<server>:5432/reviewdb"
              username="readonlyaccount" password="****" maxTotal="100" maxIdle="30"
              maxWaitMillis="10000"/>

I got this error in localhost.2014-11-20.log
20-Nov-2014 03:16:23.319 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter guiceFilter
 java.lang.NullPointerException
        at com.google.gerrit.httpd.WebAppInitializer.createDbInjector(WebAppInitializer.java:222)
        at com.google.gerrit.httpd.WebAppInitializer.init(WebAppInitializer.java:139)
        at com.google.gerrit.httpd.WebAppInitializer.getInjector(WebAppInitializer.java:349)
        at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:47)
        at com.google.gerrit.httpd.WebAppInitializer.init(WebAppInitializer.java:356)
        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4594)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5201)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

 And these severe in catalina-daemon.out
20-Nov-2014 03:16:23.320 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error filterStart
20-Nov-2014 03:16:23.320 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
20-Nov-2014 03:16:23.328 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks The web application [] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@62b143b0]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@63d30a6e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
20-Nov-2014 03:16:23.328 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks The web application [] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@3451eef5]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@6f1f31a8]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.


Am I missing some config?

Kenny Ho

unread,
Nov 19, 2014, 2:55:36 PM11/19/14
to repo-d...@googlegroups.com
And for reference, my setenv.sh is this:

#! /bin/sh
export JAVA_HOME=/usr/java/jdk1.7.0_67/
export TOMCAT_USER=gerritcr
export CATALINA_OPTS="-Dgerrit.site_path=/home/gerritcr/gerrit/ -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"

Alex Blewitt

unread,
Nov 19, 2014, 2:58:36 PM11/19/14
to Kenny Ho, repo-d...@googlegroups.com
Have you granted ‘readonlyaccount’ administrive priviledges n the Postgresql database? If so, why is it called ‘readonlyaccount’? Can you connect to it using the same host/port combination with a command line tool with the same user and password?

Alex

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenny Ho

unread,
Nov 19, 2014, 4:26:50 PM11/19/14
to repo-d...@googlegroups.com, y2k...@gmail.com
I am sharing the database between master and slave and want to make sure the slaves won't do any funny business to the database.  Does the slave/mirror need write access/admin access to the database?  I was able to get a mirror with a read-only account with mysql but I am not sure if there are any differences for Postgres.

Also, I get the same error when I switch the context.xml to use the master's db account.

Kenny

Kenny Ho

unread,
Nov 19, 2014, 6:40:10 PM11/19/14
to repo-d...@googlegroups.com, y2k...@gmail.com
Ok... I found the issue.  When I put the credential in context.xml I thought the [database] section in gerrit.config is not used any more for tomcat but that is not the case.  For more experience Tomcat admins out there, are both the gerrit.config and Tomcat conf/context.xml used?  I am not sure what the relationship is between those two configs (they both configure the database.)

Bassem Rabil

unread,
Nov 20, 2014, 7:59:44 AM11/20/14
to repo-d...@googlegroups.com, y2k...@gmail.com
When you deploy Gerrit using tomcat, the context.xml is used to get information to connect to DB when Gerrit application is launched, however for example if you run other Gerrit operations like "init" or "reindex", this will refer to the default gerrit.config configurations. That is why we keep both configs up-to-date to ensure consistency for all Gerrit operations.

Regards
Bassem
Reply all
Reply to author
Forward
0 new messages