无法在Java CMIS中获得Alfresco 4.2存储库会话

时间:2017-04-15 14:04:57

标签: alfresco alfresco-share opencmis

我想获得Alfresco 4.2.1存储库的会话。但我没有得到低于例外

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Cannot access "https://test.uk.corplan.net/alfresco/api/-default-/public/cmis/versions/1.1/atom": handshake alert:  unrecognized_name
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:228)
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invokeGET(DefaultHttpInvoker.java:55)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:615)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:782)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:65)
at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:88)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:133)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:111)
at com.rave.utils.GetAlfrescoSession.getalfrescosession(GetAlfrescoSession.java:42)
at com.rave.utils.GetAlfrescoSession.main(GetAlfrescoSession.java:18)Caused by: javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name
at sun.security.ssl.ClientHandshaker.handshakeAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:203)

我写了下面的代码来获取会话。但我在这里没有弄错。

import java.util.HashMap;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class GetAlfrescoSession {
    public static void main(String[] args) {
        getalfrescosession();
    }

    public static Session getalfrescosession() {
        Map<String, String> parameter = new HashMap<String, String>();
        parameter.put(SessionParameter.USER, "admin");
        parameter.put(SessionParameter.PASSWORD, "admin");
        parameter.put(SessionParameter.ATOMPUB_URL,
                "https://test.uk.corplan.net/alfresco/api/-default-/public/cmis/versions/1.1/atom");
        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Session session = factory.getRepositories(parameter).get(0).createSession();
        return session;
    }
}

有人可以帮助我吗?

提前致谢...

4 个答案:

答案 0 :(得分:4)

我相信您使用的网址仅与Alfresco 5.x兼容。如果您使用Alfresco 4.2.x,则需要使用其他URL。只需打开页面:

http://<your alfresco>/alfresco/s/cmis/index

您应该获得与您的实例相关的所有详细信息。 CMIS回购的URL应为:

http://<your alfresco>/alfresco/cmisatom

答案 1 :(得分:4)

这与Alfresco或OpenCMIS无关。 SSL未在服务器上正确设置。

看到这个答案: SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0

答案 2 :(得分:1)

我刚安装了最新的Alfresco 4.2.x并检查了网址:

http://127.0.0.1:8080/alfresco/s/cmis/index

然后,我点击了名为AtomPub Service Document的屏幕截图中突出显示的链接,CMIS服务的URL是:

http://127.0.0.1:8080/alfresco/cmisatom

请注意,Alfresco 4.2仅支持CMIS 1.0而不支持CMIS 1.1。

enter image description here

答案 3 :(得分:0)

我在5.1版之前遇到过这个问题,为我修复的是以下设置:

            SessionFactory factory = SessionFactoryImpl.newInstance();
            Map<String, String> parameters = new HashMap<String, String>();

            // user credentials
            parameters.put(SessionParameter.USER, "username");
            parameters.put(SessionParameter.PASSWORD, "password");

            // connection settings
            parameters.put(SessionParameter.ATOMPUB_URL, "https://someurl.com/alfresco/cmisatom");
            parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
            parameters.put(SessionParameter.REPOSITORY_ID, "IMPORTANT! the repository id must be defined here");

            // create session
            Session session = factory.createSession(parameters);

如果您使用的是4.2版,则需要验证连接端点和您正在使用的CMIS版本是否兼容。