我正在尝试 Gitblit ,这对于 Git 来说似乎是一个很好的网络用户界面。通过 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

只要我尝试导航第一级(因此, pom.xmlsrc )一切都很好,我可以正确打开和读取文件。但是,当我尝试打开 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 页面,说明未找到该文件。如果我尝试与以前相同的技巧( %2F/ ),那么我会收到此异常:
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 ),所以我的问题可能存在于错过的配置中,但我可以弄清楚在哪里。任何提示?

最佳答案



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



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

关于Gitblit:导航到二级文件夹时的错误请求,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15761920/

10-13 07:32