4


我正在尝试Gitblit,这对于 Git 来说似乎是一个相当不错的 web-UI。通过 war 文件进行安装非常简单,而且开箱即用。但是,我遇到了一个奇怪的问题。
我正在共享一个具有标准文件夹结构的 Maven 项目

project
   pom.xml
   src
   src/test-file.txt (I added this file to verify the issue)
   src/java
   src/java/main
   src/java/main/package
   src/java/main/package/File.java

只要我尝试导航第一级(so, pom.xmland src)一切都很好,我可以正确打开和读取文件。但是,当我尝试打开java下的文件夹src时,链接会呈现为localhost:8080/gitblit/tree/project/commit-id/src%2Fjava并且我会看到一个白页。请求不会转发到服务器(如果有帮助的话,tomcat 7.0.32),firebug 只是告诉我Error 400: Bad Request
%2F看起来很奇怪,所以我手动尝试修复 中的链接localhost:8080/gitblit/tree/project/commit-id/src/java,但随后生成了内部服务器错误。看着日志,我读到

INFO  Found more URL path parts then expected, these will be ignored. Url: 'http://localhost:8080/gitblit/tree/project/commit-id/src/java', mountpath: 'blob', urlPath: 'project/commit-id/src/java', expected 3 parameters was 4

然后,我添加了test-file.txt. 如果我导航到src并尝试打开test-file.txt,首先链接会尝试打开localhost:8080/gitblit/blob/project/commit-id/src%2Ftest-file.txt,显示一个 html 页面,说明找不到文件。如果我尝试与以前相同的技巧(%2Fto /),那么我会收到此异常:

INFO  Found more URL path parts then expected, these will be ignored. Url: 'http://localhost:8080/gitblit/blob/project/commit-id/src/test-file.txt', mountpath: 'blob', urlPath: 'project/commit-id/src/test-file.txt', expected 3 parameters was 4
ERROR /path/to/project/.git cant find {1} in tree {2}
org.eclipse.jgit.errors.IncorrectObjectTypeException: Object commit-id is not a blob.
    at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:130)
    at org.eclipse.jgit.lib.ObjectDatabase.open(ObjectDatabase.java:176)
    at org.eclipse.jgit.lib.Repository.open(Repository.java:278)
    at com.gitblit.utils.JGitUtils.getByteContent(JGitUtils.java:563)
    at com.gitblit.utils.JGitUtils.getStringContent(JGitUtils.java:596)
    at com.gitblit.wicket.pages.BlobPage.<init>(BlobPage.java:133)
    at sun.reflect.GeneratedConstructorAccessor22.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:89)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:305)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
    at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
    at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
    at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
    at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
    at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
    at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
ERROR Can't instantiate page using constructor public com.gitblit.wicket.pages.BlobPage(org.apache.wicket.PageParameters) and argument r = "project" h = "commit-id" f = "src"
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public com.gitblit.wicket.pages.BlobPage(org.apache.wicket.PageParameters) and argument r = "project" h = "commit-id" f = "src"
    at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:89)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:305)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
    at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
    at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
    at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
    at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
    at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
    at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedConstructorAccessor22.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188)
    ... 27 more
Caused by: java.lang.NullPointerException
    at com.gitblit.wicket.pages.BlobPage.generateSourceView(BlobPage.java:142)
    at com.gitblit.wicket.pages.BlobPage.<init>(BlobPage.java:134)
    ... 31 more

我基本上没有配置 gitblit 本身(没有更改gitblit.properties),所以我的问题可能存在于错过的配置中,但我可以弄清楚在哪里。有什么提示吗?

4

2 回答 2

3

gitblit.properties 没有变化

这句话是造成麻烦的那句话。该解决方案在Gitblit.com FAQ上有很好的记录。

在 Tomcat 上运行 Gitblit
Tomcat 采取了额外的预防措施,即默认情况下不允许嵌入斜杠。这会破坏 Gitblit 网址。对于如何处理这种情况,您有几个选项:
1.调整 Tomcat 将 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true 添加到 CATALINA_OPTS 或 JVM 启动参数
2.使用以下之一修改 gitblit.properties :
- web.mountParameters = false 并使用不漂亮的参数化网址
- web.forwardSlashCharacter = ! 它告诉 Gitblit 使用 ! 代替 /

我使用web.forwardSlashCharacter = !,从管理器重新加载 gitblit webapp,现在一切正常。我的错是我没有仔细阅读常见问题解答,直到James Morger建议我进行讲座。

于 2013-04-03T10:46:47.413 回答
2

解决这个愚蠢问题的简单方法是在 /var/lib/tomcat7/gitblit.properties中禁用挂载 URL :

请按照以下简单步骤操作:

  1. 纳米/var/lib/tomcat7/webapps/gitblit/WEB-INF/data/gitblit.properties
  2. 找到 web.mountParameters = true并更改为 false
  3. 重启tomcat /etc/init.d/tomcat7 restart
  4. 就这样 !

啊!

于 2013-05-25T21:03:45.600 回答