AnsweredAssumed Answered

ExternalAccessServlet and portlets

Question asked by doblek on Mar 6, 2007
Hi,

I've made a portlet that connects to the Alfresco webapp through the ExternalAccessServlet, IFrames and WebServices. The portlet manages the sessions and redirects to the appropiate node thanks to the ExternalAccessServlet.

Everything works fine except in one case: some registered user makes the portlet render, and then is the guest user who is willing to access the portlet. In that case, Alfresco throws an exception (saying "Failed to authenticate as Guest User" because "session is not valid" —see the quoted text—), though if I make the portal to render the portal page again, it works.
It's weird because if it's another registered user who is accessing the portlet after the first registered user, it works…

16:50:59,406 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/alfresco].[externalAccess]] Servlet.service() para servlet externalAccess lanzó excepción
org.alfresco.error.AlfrescoRuntimeException: Failed to authenticate as Guest user.
at org.alfresco.web.app.servlet.AuthenticationHelper.authenticate(AuthenticationHelper.java:209)
at org.alfresco.web.app.servlet.BaseServlet.servletAuthenticate(BaseServlet.java:124)
at org.alfresco.web.app.servlet.ExternalAccessServlet.service(ExternalAccessServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalStateException: setAttribute: La Sesión ya ha sido invalidada
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1247)
at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:129)
at org.alfresco.web.app.servlet.AuthenticationHelper.authenticate(AuthenticationHelper.java:180)
… 17 more

To sum up portlet functionality (supposed that Alfresco webapp is deployed in the same machine where the portal is deployed and it's accessible at "http://localhost:8080/alfresco"):

portlet detects if the user who is viewing the portlet has changed since the last render phase. If so:
     - if there is a session opened, logout:
               send in response an IFRAME html tag with src="http://localhost:8080/alfresco/navigate/logout"
               end the session using the webservices (the ticket created is no more needed)
     - if there is no session opened (the user was "guest user"), just send an IFRAME html tag with src="http://localhost:8080/alfresco/navigate/logout"
     - Then, in both cases, creates the ticket needed:
               · if actual user is guest: ?guest=true
               · if actual user is a registered user: starts a new session using web services and retrieves the new ticket
     - Finally, the URL we want to navigate is created using the ticket, and it's sended using an IFRAME html tag:
          <IFRAME SRC="http://localhost:8080/alfresco/navigate/browse/workspace/store/uuid?guest=true">
          or
          <IFRAME SRC="http://localhost:8080/alfresco/navigate/browse/workspace/store/uuid?ticket=TICKET_xxxxxxxxxx">

If it detects no user change, it does nothing.


Am I seeing the expected behaviour of the servlet? If I navigate that URLs in the web browser I get a different result   :cry:

Does anyone know how can I solve this issue?

Please, respond as soon as possible… it's some kind of urgent =(

Thanks in advance for the advices.

Regards,
Enrique


PS: I'm using Alfresco 1.3 for the moment…

Outcomes