Andrea Girardi
Andrea Girardi

Reputation: 4427

Alfresco 5.0: AuthenticationUtils.startSession generate 404

I'm working on an old project and, due to the short time to deploy new release, I cannot migrate the upload of content using CMIS so, I need to use old WebServiceFactory code to create binary into Alfresco.

But, with the new release of Alfresco (5.0.a) I'm not able to obtain the authorization using:

WebServiceFactory.setEndpointAddress("http://localhost:8080/alfresco/api");             
AuthenticationUtils.startSession(userName, password);

This is the error I'm getting:

Caused by: (404)Not Found
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

Any clue? Do you know if there a really (really really) fast way to create folder and update binary from Java classes?

thanks,
Andrea

Upvotes: 0

Views: 687

Answers (2)

Nicola Baiocco
Nicola Baiocco

Reputation: 156

The problem is related only to the start of the first session, in our case, because the WebServiceFactory try to load the file "alfresco/webserviceclient.properties" by default.

We've resolved the issue with this workaround:

public static void startSession(String endpoint, String username, String password)
                throws Exception {

    try {
        if (_log.isDebugEnabled()) {
            _log.debug("Connecting to: " + endpoint);
        }
        /** fix for http 404 error during start first session
         *  needs to init {@link WebServiceFactory#loadedProperties} field to true and nothing else
         */
        WebServiceFactory.getEndpointAddress();
        /** fix for http 404 error during start first session*/

        WebServiceFactory.setEndpointAddress(endpoint);

        AuthenticationUtils.startSession(username, password);
        if (_log.isDebugEnabled()) {
            _log.debug("Start session with ticket: " + AuthenticationUtils.getTicket());
        }

    }
    catch (Exception e) {
        _log.error("Can not initiate session with Alfresco server.");
        throw e;
    }
}

Upvotes: 1

Jeff Potts
Jeff Potts

Reputation: 10538

Go grab the File Loader example from this code, edit the pom.xml to the latest version of everything, point it at your server, run, enjoy.

Upvotes: 2

Related Questions