How to deploy gerrit.war to Tomcat server?

2,123 views
Skip to first unread message

samu...@gmail.com

unread,
Jun 17, 2014, 1:10:22 PM6/17/14
to repo-d...@googlegroups.com
How to deploy gerrit.war to Tomcat server?  I am not able to deploy it from the web application manager page of Tomcat.

what does it do to run the batch command: "gerrit.sh start"?

when I run "gerrit.sh start", I got error: "Starting Gerrit Code Review: FAILED"

C:\Gerrit\bin>gerrit.sh start
Welcome to Git (version 1.9.0-preview20140217)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
C:\Gerrit\bin\gerrit.sh: line 292: ulimit: virtual memory: cannot modify limit:
Invalid argument
Starting Gerrit Code Review: FAILED

Hugo Arès

unread,
Jun 17, 2014, 1:32:15 PM6/17/14
to repo-d...@googlegroups.com
Are you trying to deploy it on tomcat OR to start it using the wrapper?

As far as I know, the wrapper is not meant to be used on Windows. You best option is to deploy it in Tomcat. When you say you are not able to deploy it using the application manager, can you give more details... I guess that the application manage says that it failed to deploy the application and if it's the case, did you look at the error messages in the Tomcat logs/localhost.<date>.log?

Hugo

samu...@gmail.com

unread,
Jun 17, 2014, 2:00:00 PM6/17/14
to repo-d...@googlegroups.com
thanks a lot for quick response.

you are right, there is errors when I deployed gerrit.war to Tomcat, it cannot create database "ReviewDb",  but the "ReviewDb" has been created successfully when I run "gerrit.sh start", created some tables manually.

Should I configure Tomcat to use MySql, is there instruction about this? or should I modify the script of "gerrit.sh" in order to run it on windows' 7?

see the error log:
SEVERE: Exception starting filter guiceFilter
Throwable occurred: com.google.inject.CreationException: Guice creation errors:

1) Cannot create ReviewDb
  while locating com.google.gerrit.server.schema.ReviewDbDatabaseProvider
  at com.google.gerrit.server.schema.DatabaseModule.configure(DatabaseModule.java:31)
  while locating com.google.gwtorm.jdbc.Database<com.google.gerrit.reviewdb.server.ReviewDb>
  at com.google.gerrit.server.schema.DatabaseModule.configure(DatabaseModule.java:29)
  while locating com.google.gwtorm.server.SchemaFactory<com.google.gerrit.reviewdb.server.ReviewDb>

1 error
    at com.google.gerrit.httpd.WebAppInitializer.init(WebAppInitializer.java:141)
    at com.google.gerrit.httpd.WebAppInitializer.getInjector(WebAppInitializer.java:324)
    at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:47)
    at com.google.gerrit.httpd.WebAppInitializer.init(WebAppInitializer.java:330)
    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:4809)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:553)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1671)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
    at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1485)
    at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:286)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:206)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2442)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2431)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:736)
Caused by: com.google.gwtorm.server.OrmException: Unable to determine SqlDialect
    at com.google.gwtorm.jdbc.Database.<init>(Database.java:81)
    at com.google.gerrit.server.schema.ReviewDbDatabaseProvider.get(ReviewDbDatabaseProvider.java:39)
    at com.google.gerrit.server.schema.ReviewDbDatabaseProvider.get(ReviewDbDatabaseProvider.java:28)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:73)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:66)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:63)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1058)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.Scopes$1$1.get(Scopes.java:65)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1058)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.Scopes$1$1.get(Scopes.java:65)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1051)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.gerrit.httpd.WebAppInitializer.createDbInjector(WebAppInitializer.java:228)
    at com.google.gerrit.httpd.WebAppInitializer.init(WebAppInitializer.java:124)
    ... 51 more
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at com.google.gwtorm.jdbc.Database.<init>(Database.java:74)
    ... 77 more
Caused by: java.lang.NullPointerException
    at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:515)
    at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:484)
    at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
    at java.sql.DriverManager.getDriver(DriverManager.java:379)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
    ... 80 more

Bassem Rabil

unread,
Jun 17, 2014, 3:21:29 PM6/17/14
to repo-d...@googlegroups.com
I think you need to specify the database connector and host in <TOMCAT dir>/conf/context.xml because it is not able to get this database configurations from gerrit.config. For example postgresql shall look like the following:
<Context path="/" docBase="gerrit" reloadable="false" useHttpOnly="true">

<Resource name="jdbc/ReviewDb" auth="Container"
 type="javax.sql.DataSource"
 driverClassName="org.postgresql.Driver"
                  url="jdbc:postgresql://<HOSTNAME>:<PORT>/reviewdb"
                  maxActive="xx"
                  maxIdle="xx"
                  maxWait="xx"
                  validationQuery="select 1" />
</Context>

Unfortunately I think this is not documented.

Regards
Bassem

Hugo Arès

unread,
Jun 17, 2014, 3:40:35 PM6/17/14
to repo-d...@googlegroups.com
As Bassem said, you need to create the jdbc resource in the Tomcat conf/context.xml so the database create by the wrapper script is available to the web application.

If you use Tomcat, you do not need the wrapper. Here are the steps you need to do:
1.Get the gerrit.war
2.initialize the gerrit site (java -jar gerrit.war init -d <someFolder>)
3.configure the jdbc resource in <TOMCAT dir>/conf/context.xml
4.copy the jar required by Gerrit to run in <TOMCAT dir>/lib: bouncy castle jars(bcpkix-jdk15on-149.jar and bcprov-jdk15on-149.jar)  and the database client jar (e.g. h2-<version>jar if using h2).
5.add -DGERRIT_SITE=<someFolder> to the CATALINA_OPTS (same folder you initialized at step 2)
6.Deploy gerrit.war.

Hugo

samu...@gmail.com

unread,
Jun 17, 2014, 3:49:11 PM6/17/14
to repo-d...@googlegroups.com
I am able to sucessfully deploy gerrit.war to tomcat, but when I access "http://localhost:8080/gerrit", got error, how can I fix the authorization error and connect to Git?

Configuration Error

Check the HTTP server's authentication settings.

The HTTP server did not provide the username in the Authorization header when it forwarded the request to Gerrit Code Review.

If the HTTP server is Apache HTTPd, check the proxy configuration includes an authorization directive with the proper location, ensuring it ends with '/':

<VirtualHost localhost:8080>
    ServerName localhost

    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
          Order deny,allow
          Allow from all
    </Proxy>

<Location /gerrit/login/> AuthType Basic AuthName "Gerrit Code Review" Require valid-user ... </Location>
AllowEncodedSlashes On ProxyPass /gerrit/ http://.../gerrit/ nodecode </VirtualHost>





On Tuesday, June 17, 2014 3:21:29 PM UTC-4, Bassem Rabil wrote:

samu...@gmail.com

unread,
Jun 17, 2014, 4:08:36 PM6/17/14
to repo-d...@googlegroups.com
I set the authorization in web.xml, then try to access "http://localhost:8080/gerrit"
but it cannot get the Git projects,  got this error:

HTTP Status 500 - Missing project All-Projects


type Exception report

message Missing project All-Projects

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException: Missing project All-Projects
	com.google.gerrit.server.project.ProjectCacheImpl.getAllProjects(ProjectCacheImpl.java:101)
	com.google.gerrit.server.account.AccountManager.create(AccountManager.java:287)
	com.google.gerrit.server.account.AccountManager.authenticate(AccountManager.java:116)
	com.google.gerrit.httpd.auth.container.HttpLoginServlet.doGet(HttpLoginServlet.java:121)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278)
	com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268)
	com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
	com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
	com.google.gwtexpui.server.CacheControlFilter.doFilter(CacheControlFilter.java:70)
	com.google.gerrit.httpd.RunAsFilter.doFilter(RunAsFilter.java:113)
	com.google.gerrit.httpd.AllRequestFilter$FilterProxy$1.doFilter(AllRequestFilter.java:64)
	com.google.gerrit.httpd.AllRequestFilter$FilterProxy.doFilter(AllRequestFilter.java:57)
	com.google.gerrit.httpd.RequestContextFilter.doFilter(RequestContextFilter.java:75)
	com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
	com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:132)
	com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:129)
	com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:206)
	com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:129)
	com.google.gerrit.httpd.WebAppInitializer.doFilter(WebAppInitializer.java:109)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.54 logs.

Hugo Arès

unread,
Jun 17, 2014, 4:14:14 PM6/17/14
to repo-d...@googlegroups.com
Did you configure the GERRIT_SITE property to point to the gerrit_site folder you initialized?

samu...@gmail.com

unread,
Jun 17, 2014, 4:15:31 PM6/17/14
to repo-d...@googlegroups.com
copied the git repository into \wabapps\gerrit\, it got different error:
Code Review - Error
500 Internal server error

Hugo Arès

unread,
Jun 17, 2014, 4:34:23 PM6/17/14
to repo-d...@googlegroups.com

You didn't configure the GERRIT_SITE property to point to the gerrit_site folder you initialized so this is why Gerrit cannot find the git repo. Copying the git repo under the deployed webapp is not a solution, think about what will happen if you deploy it again?

CONFIGURE the GERRIT_SITE property to point to the gerrit_site you initialized. You can do this by adding this to the CATALINA_OPTS: -DGERRIT_SITE=<someFolder>

Zu, Bruce

unread,
Jun 17, 2014, 11:22:55 PM6/17/14
to samu...@gmail.com, repo-d...@googlegroups.com

Did you check ‘All-Projects.git’ exists or not under ‘<site>/git/’ ?

If it exists

How about try  :

cd  path/to/tomcat/webapps

//Clean any package and file there

ln –s  <Gerrit site>/bin/gerrit.war  ./ROOT.war

//restart tomcat

--
--
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.

samu...@gmail.com

unread,
Jun 19, 2014, 11:30:16 AM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
There is no ‘All-Projects.git’  under ‘<site>/git/’

Bassem Rabil

unread,
Jun 19, 2014, 12:54:35 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
Gerrit wouldn't start unless All-Projects.git exists because this repository stores the Gerrit application preferences and settings. Did you initialize your site using ?
java -jar gerrit.war init -d site_path

samu...@gmail.com

unread,
Jun 19, 2014, 1:25:15 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
yes, after I executed  "java -jar gerrit-2.8.1.war init -d c:\gerrit", it created git folder in c:\gerrit, but  there is no ‘All-Projects.git’  under ‘c:\gerrit\git\’

here is what I did,
I ran "java -jar gerrit-2.8.1.war init -d c:\gerrit" , it copied the war file to c:\gerrit\bin\gerrit.war,  then deployed the "c:\gerrit\bin\gerrit.war" to Tomcat on the Application Manager page,  after that, modified the file "conf\context.xml" to add resource name of DB, <Resource name="jdbc/ReviewDb" ...
modified the file C:\Tomcat7\webapps\gerrit\WEB-INFweb.xml,  added <resource-ref>... and  <security-constraint>...
restart Tomcat, there is no error, Gerrit is started, copied \git from c:\gerrit   to  \webapps\gerrit\

when I access http://localhost:8080/gerrit/, there is error:
[2014-06-19 13:18:59,531] ERROR com.google.gerrit.httpd.restapi.RestApiServlet :
 Error in GET /gerrit/accounts/self/capabilities?q=createProject&q=createGroup&q
=administrateServer
java.lang.IllegalStateException: Missing project All-Projects



here is init information,
C:\Gerrit>java -jar gerrit-2.8.1.war init -d c:\gerrit
...
Location of Git repositories   [git]:

Authentication method          [HTTP/?]:
Get username from custom HTTP header [y/N]? Y
Username HTTP header           [SM_USER]: gerrit2
...
Run as                         [gerrit2]:
Java runtime                   [C:\Program Files (x86)\IBM\SDP75\jdk\jre]:
Upgrade c:\gerrit\bin\gerrit.war [Y/n]?
Copying gerrit-2.8.1.war to c:\gerrit\bin\gerrit.war

*** SSH Daemon
***
Listen on address              [localhost]:
Listen on port                 [8443]:

*** HTTP Daemon
***
Behind reverse proxy           [y/N]?N
Use SSL (https://)             [y/N]?N
Listen on address              [*]:localhost
Listen on port                 [8080]:
Canonical URL                  [http://localhost:8080/]:

*** Plugins
***

Install plugin download-commands version v2.8.1 [y/N]?
Install plugin reviewnotes version v2.8.1 [y/N]?
Install plugin replication version v2.8.1 [y/N]?
Install plugin commit-message-length-validator version v2.8.1 [y/N]?

Initialized C:\Gerrit

Hugo Arès

unread,
Jun 19, 2014, 2:16:10 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
I just tested the site initialization using gerrit 2.8.1 on window7 and the All-Projects.git is created under the <site>/git folder.
Can you try the site initialization again using the java -jar .... command but remove the previous site before, Maybe it failed at one point and now it is not creating the All-Projects because it is updating the site instead of creating it.

Hugo

samu...@gmail.com

unread,
Jun 19, 2014, 2:54:07 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
thanks, I tried many times, there is no All-Projects.git under the <site>/git folder or c:\dataGit\GitProject

I tried with parameters of "git" and "c:\dataGit\GitProject"("c:\dataGit\GitProject" is my local git repository)
Location of Git repositories   [git]: git
Location of Git repositories   [git]: c:\dataGit\GitProject

I am curious, why the same command gave different results, is there difference?

samu...@gmail.com

unread,
Jun 19, 2014, 3:23:20 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
after I dropped all the tables and redid the init, there is All-Projects.git, let me redeploy again

samu...@gmail.com

unread,
Jun 19, 2014, 3:27:18 PM6/19/14
to repo-d...@googlegroups.com, samu...@gmail.com
I just copied "All-Projects.git" to site\git\, then it works fine, there is no error, thanks a lot.

Ankush Thakur

unread,
Jun 2, 2015, 12:56:52 PM6/2/15
to repo-d...@googlegroups.com
Hi Samuel & Hugo,

Please help me in setting up Gerrit on Windows7, I have followed below link for setup gerrit on tomcat
http://scn.sap.com/docs/DOC-42271

After setup completion I am hitting http://localhost:8080/gerrit url to get my gerrit page but it says 404 not found. I don't know where I missed the things.
Even when I am executing "gerrit.sh start" from cmd it says "gerrit.sh: line 292: ulimit: virtual memory: cannot modify limit: Invalid argument

Starting Gerrit Code Review: FAILED"

I have setup JDBC, Tomcat for this.
Can you guy help me or can I have a complete steps for setup.

Thanks,
Ankush

Righardt Marais

unread,
Jun 17, 2015, 10:18:41 AM6/17/15
to repo-d...@googlegroups.com
Hi Ankush

Have you managed to get your gerrit installed on windows?
I am trying to get mine installed and configured, but I can't seem to find a good enough guide to instruct - step 1, step 2, step 3

Tx
Righardt
Reply all
Reply to author
Forward
0 new messages