cancel
Showing results for 
Search instead for 
Did you mean: 

alfresco can't start session

yassine_036
Champ in-the-making
Champ in-the-making
hi
i'm trying to run an example for alfresco web script
i have to authenticate, for this i use the fonction AuthenticationUtils.startSession but i have some error
this is my code:
WebServiceFactory.setEndpointAddress("http://127.0.0.1:8080/alfresco/api");
       
      // Start the session
       AuthenticationUtils.startSession(getUser(), getPassword());
      
      //AuthenticationUtils.startSession("admin", "admin");
      
        try {
           // Create a reference to the parent where we want to look for content
           Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
           

            // Get a reference to the respository web service
            RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();        

            // Create a query object, looking for all items of a particular type
            Query query = new Query(Constants.QUERY_LANG_LUCENE, "TYPE:\"" + Constants.createQNameString(SomeCoModel.NAMESPACE_SOMECO_CONTENT_MODEL, SomeCoModel.TYPE_SC_DOC) + "\"");
and this is the error what i have
Exception in thread "main" org.alfresco.webservice.util.WebServiceException: Error starting session.
   at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:94)
   at com.someco.examples.SomeCoDataCleaner.clean(SomeCoDataCleaner.java:42)
   at com.someco.examples.SomeCoDataCleaner.main(SomeCoDataCleaner.java:35)
Caused by: (400)Mauvaise Requ�te
   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)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub.startSession(AuthenticationServiceSoapBindingStub.java:187)
   at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:79)
   … 2 more
i use eclipse JEE
Tomcat 6
alfresco 3.0
alfresco sdk 2.9
thanks for your help
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
First, can you post your full class, any output the class generates, and your catalina.out? It's hard to help debug with just a partial listing.

Also, you said you are running Alfresco 3.0 but SDK 2.9. Was that a typo or are you purposefully running a mismatched repository and SDK? You might try re-compiling against the 3.0 SDK and trying again.

Also double-check that you've got a webserviceclient.properties file in your classpath that contains:

#
# Set the following property to reference the Alfresco server that you would like web service client
# to communicate with
repository.location=http://localhost:8080/alfresco/api

Jeff

shai
Champ in-the-making
Champ in-the-making
Hi,
I'm suffering from the same problem, though I'm using Alfresco 3.0 both on the server and the sdk.
I try:
AuthenticationUtils.startSession(”admin”, “admin”);
but it throws an axis exception that translates to 400 bad http request.

I tried looking at the code and it seems to throw that exception after invoking the call it creates.

I already verified that the call is indeed to my server's address, and I'm quite stuck..

Thanks,
Shai

jpotts
World-Class Innovator
World-Class Innovator
I know you are doing a Web Services call, but can you verify that you can login via the /api/login web script, like this:

curl "http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin" 
Is this a custom class, one of the SDK examples, or one of the Someco examples?

Jeff

divyank
Champ in-the-making
Champ in-the-making
Iam getting the same error session is not getting started  Iam using the code below to download a file

public String webService(String dir, String fileName)   throws Exception

{

String downloadURL = null;
try {

System.out.println("dir ::" + dir);

System.out.println("fileName ::" + fileName);

// Start the session
   WebServiceFactory.setEndpointAddress("http://127.0.0.1:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "Password123");

String ticket = AuthenticationUtils.getTicket();

// Create a reference to the parent where we want to create content

Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

// Reference reference = new Reference(storeRef, null,

// "/app:company_home/cmsmileyCMCOE/cm:COE1/*[@cm:name=\"" +

// "eProfilerPPT" + "\"]");

// Create a new Reference to the node you want (variable path here).

String path = dir + "*[@cm:name=\"" + fileName + "\"]";

Reference reference = new Reference(storeRef, null, path);

ContentServiceSoapBindingStub contentService = WebServiceFactory

.getContentService();

// Read the content from the respository

Content[] readResult = contentService.read(new Predicate(

new Reference[] { reference }, storeRef, null),

Constants.PROP_CONTENT);

Content contentRef = readResult[0];

// Get the ticket URL as above and the downloadURL here points to

// the url where the content is present.

System.out.println("contentRef.getUrl() : " + contentRef.getUrl());

String ticketURL = "?ticket=" + ticket;

downloadURL = contentRef.getUrl() + ticketURL;

System.out.println("downloadURL in webService(): " + downloadURL);

} catch (Throwable e) {

System.out.println(e.toString());

} finally {

// End the session

// AuthenticationUtils.endSession();

}

return downloadURL;

}

Iam getting the following error:  org.alfresco.webservice.util.WebServiceException: Error starting session.

gravitonian
Star Collaborator
Star Collaborator
As Jeff Potts is saying earlier on in this thread: can you login with the credentials you are using:

curl "http://localhost:8080/alfresco/service/api/login?u=admin&pw=Password123"