cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with getting ticket and ThreadLocal

karkaletsis
Champ in-the-making
Champ in-the-making
I use web services API from liferay to browse the alfresco content. I first login (start session) and then I use the practice you propose with the callback handler. The problem is that threadlocal class that keeps the authentication variables is being overrided in every new login of alfresco. So this is a serious proble.

It seems to me that threadlocal not works as it suppose, or every request is the same thread.

Any help on this strange issue.

Piece of code:

public class AuthenticationUtils implements CallbackHandler
…..
private static ThreadLocal<AuthenticationDetails> authenticationDetails = new ThreadLocal<AuthenticationDetails>();
8 REPLIES 8

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

I've not seen this behavior, but it does sound like a problem.

The was the ticket is stored between web service calls is entirely up to you.  The AuthenticationUtils is an example of how things can be done, but by no means the only way.

I'd suggest taking the AuthenticationUtils class as a basis and writing your own mechanism for storing the ticket between web service calls, that work within your environment.

Cheers,
Roy

stevewickii
Champ in-the-making
Champ in-the-making
I don't believe this problem has anything to do with the Alfresco webservice client API.

The following JSP can be used to show that regardless of the Thread starting the session, Alfresco returns the same ticket number when two sessions start with the same username.  This is the real problem.  Alfresco should not return the same ticket number when startSession() is invoked multiple times for a single username.  Every time startSession() is invoked a new ticket should be created.

Add test.jsp to your web application with the webservice API, and open the test.jsp url in two different browsers.

test.jsp sleeps for 30 seconds to give you time to open test.jsp in another browser, which will start a concurrent session.

Note that the Thread is different but the Ticket is the same for both browsers.

test.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@page import="org.alfresco.webservice.util.AuthenticationUtils"%>
<pre>
Testing Alfresco Connectivity

<%
   AuthenticationUtils.startSession("website", "website");
%>
Started Alfresco Session

Ticket: <%=AuthenticationUtils.getTicket()%>

Thread: <%=Thread.currentThread()%>

Sleeping 30 seconds

<%
   out.flush();
   Thread.currentThread().sleep(30000);
%>
<%
   try
   {
      AuthenticationUtils.endSession();
   }
   catch(Exception e)
   {
      request.setAttribute("endSessionException", e);
   }
%>
<c:choose>
<c:when test="${!empty endSessionException}">Error Ending Alfresco Session
   <table border=1><tr><td>${endSessionException}</td></tr></table>
</c:when>
<c:otherwise>Closed Alfresco Session</c:otherwise>
</c:choose>
</pre>

Invocation 1:

Testing Alfresco Connectivity


Started Alfresco Session

Ticket: TICKET_ea351ff97650d807dd9c93f1428fca28f13d7689

Thread: Thread[http-8080-1,5,main]

Sleeping 30 seconds

Ended Alfresco Session

Invocation 2: (Concurrent to Invocation 1)

Testing Alfresco Connectivity

Started Alfresco Session

Ticket: TICKET_ea351ff97650d807dd9c93f1428fca28f13d7689

Thread: Thread[http-8080-3,5,main]

Sleeping 30 seconds

Error Ending Alfresco Session
   org.alfresco.webservice.util.WebServiceException: Error ending session.

stevewickii
Champ in-the-making
Champ in-the-making
This issue was resolved by the following JIRA ticket
http://issues.alfresco.com/browse/AR-1623

The latest nightly build of Alfresco (2.9.0B build 683) fixes this issue.

Cheers!

federico_tesei
Champ in-the-making
Champ in-the-making
Hi to all,
             my scenario is Alfresco 2.1 Community ( 2007-07-24 ) on Jboss 4.2            
Near delivery deadline of the pilot project I'm experiencing the 'Callback supplied no password for ticket' problem.
I'm wondering how to fix this problem in the fastest and reliable way.
The bug has been fixed on Afresco 2.1.0 Enterprise but as we are still on a eveluation stage we can' t purchase the Enterprise yet.
I' ve seen that there is Alfresco 2.9 Community beta available but I'm looking for a more stable version.
I'm falling back to Alfresco 2.0 community as  this version, delivering a ticket for each session request made [even by the same user], should fix the problem.
Am I mistaken ?
Does anyone have direct experience that Alfresco 2.0 Community fix this problem ?

thanks to all in advance

federico

mikeh
Star Contributor
Star Contributor
Hi

You can get a 30-day evaluation of the Enterprise version to test your config on.

Thanks,
Mike

federico_tesei
Champ in-the-making
Champ in-the-making
Thanks Mark for your quick reply but 30 days for a Department of a public Administration is just a moment Smiley Happy

thanks again

federico

mikeh
Star Contributor
Star Contributor
Who's Mark? 😉

The 30 day trial can be extended in certain circumstances if required. Please speak to our sales guys if you do want to explore this avenue.

Thanks,
Mike

sacco
Champ in-the-making
Champ in-the-making
Thanks Mark for your quick reply but 30 days for a Department of a public Administration is just a moment Smile

Già!  Si potrebbe dire anche 30 settimane…