我正在尝试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.xml
和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页面,指出找不到该文件。如果我尝试与之前相同的技巧(%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
),所以我的问题可能在于错过配置,但我可以找出原因。任何提示?
答案 0 :(得分:3)
gitblit.properties没有变化
这句话引起了麻烦。并且Gitblit.com FAQ已经很好地记录了解决方案。
在Tomcat上运行Gitblit Tomcat采取disallowing embedded slashes by default的额外预防措施。这打破了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建议我讲课之前,我没有仔细阅读常见问题解答。
答案 1 :(得分:2)
解决这个愚蠢问题的简便方法是在/var/lib/tomcat7/gitblit.properties中禁用挂载网址:
按照以下简单步骤操作:
氰!