我正在使用svnkit(独立版1.8.12)用Java签出svn存储库。
我尝试了几种方法(12)。不幸的是,一旦SVNkit开始连接到SVN服务器,它就会崩溃并显示以下堆栈跟踪信息(签出,测试连接,获取修订号等)。通过终端签出效果很好(使用安装了Subversion的Ubuntu 14),也可以通过浏览器打开使用的repo-url效果很好。

Exception in thread "main" java.lang.IndexOutOfBoundsException: Bounds exceeds available space : size=7, offset=8
at com.sun.jna.Memory.boundsCheck(Memory.java:185)
at com.sun.jna.Memory.getPointer(Memory.java:509)
at org.tmatesoft.svn.core.internal.util.jna.SVNGnomeKeyring.setPassword(SVNGnomeKeyring.java:334)
at org.tmatesoft.svn.core.internal.util.jna.SVNGnomeKeyring.setPassword(SVNGnomeKeyring.java:308)
at org.tmatesoft.svn.core.internal.util.jna.SVNJNAUtil.addPasswordToGnomeKeyring(SVNJNAUtil.java:170)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNPersistentAuthenticationProvider$GnomeKeyringPasswordStorage.savePassword(DefaultSVNPersistentAuthenticationProvider.java:696)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNPersistentAuthenticationProvider.savePasswordCredential(DefaultSVNPersistentAuthenticationProvider.java:416)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNPersistentAuthenticationProvider.saveAuthentication(DefaultSVNPersistentAuthenticationProvider.java:323)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.acknowledgeAuthentication(DefaultSVNAuthenticationManager.java:274)
at org.tmatesoft.svn.core.auth.BasicAuthenticationManager.acknowledgeAuthentication(BasicAuthenticationManager.java:105)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:771)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:398)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:386)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:863)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:699)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:118)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1049)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.testConnection(DAVRepository.java:100)
at Main.svnCheckout(Main.java:131)
at Main.svnCheckoutPrep(Main.java:106)
at Main.main(Main.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)


产生此错误的代码如下

    static void svnCheckout(String url, String dest) throws SVNException {
    /* Setup SVNKIT library */
    setupSVNKit();

    SVNRepository repository = null;
    try {
        repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
    } catch (SVNException svne) {
        System.err.println("error while creating an SVNRepository for the location '"
                        + url + "': " + svne.getMessage());
        System.exit(1);
    }
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("someName", "somePWD");
    repository.setAuthenticationManager(authManager);
    repository.testConnection();
    }


...

    static void setupSVNKit(){
    /* For using http:// and https:// */
    DAVRepositoryFactory.setup();
    }


有谁知道我做错了什么?
如果只有testConnection()函数可以工作,我会很高兴。
既然是https,我是否需要设置SVNkit来接受指纹或类似的东西?

任何帮助深表感谢!
 马库斯

最佳答案

好吧,经过多次尝试和错误,我终于明白了。实际上,我在使用另一个存储库时遇到了另一个错误。我做了两件事(不确定是哪一个是真正的原因,也许都是)。


将不受信任的证书(是未经验证的)添加到了JVM
将以下行添加到VM选项:-Dsvnkit.library.gnome-keyring.enabled=false


进一步阅读:

点1:https://issues.tmatesoft.com/issueMobile/SVNOLD-290

点2:https://issues.tmatesoft.com/issue/SVNKIT-231

关于java - SVNKit java.lang.IndexOutOfBoundsException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35473399/

10-10 22:46