cancel
Showing results for 
Search instead for 
Did you mean: 

Can not connect to a repository

n3k
Champ in-the-making
Champ in-the-making
Hello,
I am very new in Alfresco and CMIS.
II tried the firs example of creating a session to a repository.
I created a maven project and I have just a main java class in which I try to create the session.
The problem is that when I try to connect to any repository I got a connection failure.
I have tried
- http://localhost:8181/opencmis/atom/
- http://localhost:8080/alfresco/cmisatom
Even in the case of public Alfresco repository http://cmis.alfresco.com/cmisatom it failes again.
The only case that instead of connection error I got an Unauthorized error is the case of  http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/atom

You will find my code below:
                // default factory implementation
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Map<String, String> parameter = new HashMap<String, String>();

      // user credentials
      parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");

      // connection settings
      parameter.put(SessionParameter.ATOMPUB_URL, "http://cmis.alfresco.com/cmisatom");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
      parameter.put(SessionParameter.REPOSITORY_ID, "97b8bac9-52dd-4667-9d0d-70d0032fddb0");
      
      // create session
      Session session = factory.createSession(parameter);

Maybe my question is too trivial but I am really confused.
Thank you in advance
Kind regards,
N3k
2 REPLIES 2

americanolinhar
Champ on-the-rise
Champ on-the-rise
Change the ATOMPUB_URL to "http://localhost:8080/alfresco/cmisatom" like the code below. Be sure your port is 8080. Be sure your Repo Id is correct.


   private static String USER = "admin";
   private static String PASSWORD = "admin";
   private static String SERVER_URL = "http://localhost:8081/alfresco/cmisatom";
   
   
   public static Session getSession(){
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Map<String, String> parameter = new HashMap<String,String>();
      
      parameter.put(SessionParameter.USER, USER);
      parameter.put(SessionParameter.PASSWORD, PASSWORD);
      
      parameter.put(SessionParameter.ATOMPUB_URL, SERVER_URL);
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
      parameter.put(SessionParameter.REPOSITORY_ID,"yourRepoID");
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

n3k
Champ in-the-making
Champ in-the-making
Hello and thank you for your response.
Nothing changes. I got the same error.
To tell the truth for localhost I can not connect not even via cmis workbench
but for public Alfersco repo I can so I could be sure for the id.

Thank you.
Kind regards,
N3k