portals-pluto-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhong ZHENG <heavyzh...@gmail.com>
Subject PLUTO 1.1 Problem: Cross context: where is the session?
Date Sun, 04 Sep 2005 19:17:36 GMT
Hi, there,

I got a problem using Pluto 1.1: since Pluto uses cross context to invoke 
portlets, if I try to retrieve a portlet session from the portlet request, 
which servlet context is this portlet session bound to?

Well, here is a simple scenario: I am writing a portlet app with a single 
portlet. This app will be deployed to the context path, for example, '/toto'. 
In the portlet, render() method retrieves an attribute from portlet session 
using key X, prints the value on the page, and provides a link to the action 
URL. The processAction() method sets the value of attribute X in the portlet 

Here comes the problem: when the action URL is triggered, the 
processAction() method runs well, BUT! When the portlet is rendered, the 
render() method fails to find the attribute.

If I don't use cross context, which is to say, if I put the toto portlet app 
into the portal driver webapp, the portlet runs perfectly.

I tried to trace the error, and found that the processAction() and render() DID 
NOT use the same portlet session: during the action processing, the portlet 
session was bound to servlet context '/pluto' (whose name was Pluto 
Reference Implementation), but during the render processing, the portlet 
session was bound to the context '/toto'. That's why render() method failed 
to retrieve the session: It created a new one with no attributes inside.

To find more details on the problem, I checked the source code. In the class 

 public PortletSession getPortletSession(boolean create) {
 // check if the session was invalidated

 // HERE!! The HttpSession is retrieved successfully,
 // but they are different for render() and processAction() methods!
 HttpSession httpSession = this.getHttpServletRequest()
 // I Debugged the name of servlet context, and they are different!
if (httpSession != null) {
 javax.servlet.ServletContext servletContext = httpSession.getServletContext
 LOG.info("Servlet context name: " + servletContext.getServletContextName
 if ((portletSession != null) && (httpSession == null)) {
 portletSession = null;
 } else if (httpSession != null) {
 create = true;

 if (create && portletSession == null) {
 httpSession = this.getHttpServletRequest().getSession(create);
 if (httpSession != null) {
 portletSession =
 new PortletSessionImpl(context, internalPortletWindow,

 return portletSession;

So I would like to ask you: If we use cross context, which servlet context 
should the portlet sessions be bound to? The portal webapp or my portlet 

Anyway, we should use the same portlet session for both processAction() and 
render(), shouldn't we? So, is this a bug?

I also tried to find out why the sessions are different for processAction()and 
render(). I found that before the PortletInvoker calls
response) to dispatch the request and response to 
/toto/PlutoInvoker/MyPortlet and pass the control to PortletServlet, the two 
methods work all the same. But when PortletServlet.dispatch() is called, 
they already behave differently: I inserted some debug codes at the begining 
of PortletServlet.dispatch() method, as the following:

LOG.debug("Servlet context name: " + ((PortletRequestImpl) request)

For portlet action requests, this code prints "Pluto Reference 
Implementation", while for rendering requests, "My Portlet App" is printed.

So I wonder if that is a problem of Tomcat?

BTW, I am using Tomcat 5.5.9 + JDK 1.4.1_05-b01

I would appreciate your response. Thanks in advance.




1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90

heavyzheng {AT} gmail {D0T} com


View raw message