Kevin Irmscher escribió:
> On 2/14/07, Diego Louzán <[EMAIL PROTECTED]> wrote:
>> Kevin Irmscher escribió:
>> > Hi!
>> >
>> > I'm developping a portlet and I want to use the PortletSession to
pass
>> > attributes between the Portlet and a JSP. This works perfectly
when I
>> > deploy the portlet locally (Pluto), but it doesn't when I access the
>> > portlet through WSRP using WSRP4J (with Pluto) as producer.
>> >
>> > Here's what I'm doing exactly:
>> > 1. invoke an actionURL in the JSP
>> > 2. processAction in the portlet will be called
>> > 3. set PortletSession attribute (the attribute is an object of
MyClass)
>> >
>> > actionRequest.getPortletSession().setAttribute("myClass", new
>> > MyClass());
>> >
>> > 4. get MyClass object in JSP
>> >
>> > <%
>> > MyClass c = (MyClass)
>> > renderRequest.getPortletSession().getAttribute("myClass");
>> > %>
>> >
>> > 5. display c.toString
>> >
>> > <% if (c != null) { %> <%=c.toString()%> <% } %>
>> >
>> >
>> > It does work if the portlet is local but not when I consume it
>> > remotely. That's why I assume it must have something to do with the
>> > WSRP4J producer implementation. I don't get any error messages
neither
>> > on the consumer nor on the producer.
>> >
>> > It is strange tough that if I use a String or an Integer object
>> > instead of MyClass it even works with WSRP4J!
>> >
>> > Any help would be appreciated,
>> > Kevin
>> >
>> > Here the code of the portlet:
>> >
>> > public class SessionTestPortlet extends GenericPortlet {
>> >
>> > public void doView(RenderRequest request, RenderResponse
response)
>> > throws PortletException, IOException {
>> >
>> > PortletContext context = getPortletContext();
>> > PortletRequestDispatcher disp =
>> > context.getRequestDispatcher("/jsp/"
>> > + "view.jsp");
>> > disp.include(request, response);
>> >
>> > }
>> >
>> > public void processAction(ActionRequest actionRequest,
>> > ActionResponse actionResponse) throws PortletException,
>> > java.io.IOException {
>> >
>> > actionRequest.getPortletSession()
>> > .setAttribute("myClass", new MyClass());
>> > }
>> > }
>> >
>> > Here the code of view.jsp:
>> >
>> > <%@ page session="true"%>
>> > <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
>> > <%@ page import="javax.portlet.*"%>
>> > <%@ page import="java.util.*"%>
>> > <%@ page import="session.test.portlet.MyClass"%>
>> >
>> > <portlet:defineObjects />
>> >
>> > <%
>> > MyClass c = (MyClass)
>> > renderRequest.getPortletSession().getAttribute("myClass");
>> > %>
>> >
>> > <%
>> > if (c == null) {
>> > %>
>> > <form action="<%=renderResponse.createActionURL()%>" method="post">
>> > <input type="submit" value="Show MyClass" /></form>
>> > <% } else { %>
>> > <%=c.toString()%>
>> > <% } %>
>>
>> Your code seems correct and besides that, if it works as a local
portlet
>> it should work exposed by WSRP4J Producer.
>>
>> Which consumer are you using? Are you sure the WSRP processAction()
>> operation is being called? Check the SOAP communication for details.
>> Take into account that the only tested Pluto version is 1.0.1, not the
>> recent 1.1.0.
>>
>> The logs (for both the consumer and producer) should give you any
clues
>> on the problem. That thing on working with Java wrapper types but not
>> with custom classes is strange. Are you sure the producer is accesing
>> the jars with your custom classes?
>>
>> You can also use netbeans or eclipse debugger to check what the
code is
>> doing as a last resort.
>>
>> Regards.
>> Diego.
>>
>
> I'm using Pluto version 1.0.1 as portlet container and Liferay as
> consumer. I checked the logs and found the exception. It is thrown in
> the moment when the attribute in the processAction method is set:
>
> actionRequest.getPortletSession().setAttribute("myClass", new
MyClass());
>
> It seems to be a serialization problem which would explain why the
> standard Java wrapper classes still work. However, I'm still not sure
> what causes the problem. I can deploy the portlet on the Pluto
> container and access it locally and it works perfectly fine. It
> doesn't seem to be a consumer problem, does it?
>
> Here the exception's stack trace:
>
> SCHWERWIEGEND: Servlet.service() for servlet sessionTestPortlet threw
> exception
> java.lang.IllegalArgumentException: setAttribute: Non-serializable
> attribute
> at
>
org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1244)
>
> at
>
org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:129)
>
> at
>
org.apache.pluto.core.impl.PortletSessionImpl.setAttribute(PortletSessionImpl.java:193)
>
> at
>
org.apache.pluto.core.impl.PortletSessionImpl.setAttribute(PortletSessionImpl.java:96)
>
> at
>
session.test.portlet.SessionTestPortlet.processAction(SessionTestPortlet.java:33)
>
> at
> org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:229)
> at
org.apache.pluto.core.PortletServlet.doPost(PortletServlet.java:163)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> org.apache.pluto.core.PortletServlet.service(PortletServlet.java:153)
> 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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
>
> at
>
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
>
> at
>
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
>
> at
>
org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:120)
>
> at
>
org.apache.pluto.invoker.impl.PortletInvokerImpl.action(PortletInvokerImpl.java:68)
>
> at
>
org.apache.pluto.PortletContainerImpl.processPortletAction(PortletContainerImpl.java:164)
>
> at
>
org.apache.pluto.portalImpl.core.PortletContainerWrapperImpl.processPortletAction(PortletContainerWrapperImpl.java:82)
>
> at
>
org.apache.wsrp4j.producer.provider.pluto.driver.PortletInvokerImpl.invokePerformBlockingInteraction(PortletInvokerImpl.java:288)
>
> at
>
org.apache.wsrp4j.commons.producer.driver.WSRPEngine.performBlockingInteraction(WSRPEngine.java:844)
>
> at
>
org.apache.wsrp4j.commons.producer.binding.WSRPMarkupBindingImpl.performBlockingInteraction(WSRPMarkupBindingImpl.java:75)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
>
> at
>
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
>
> at
>
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
> 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.handlers.soap.SOAPService.invoke(SOAPService.java:454)
> at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
> at
> org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at
>
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
>
> 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)
>
> Regards,
> Kevin
I don't remember getting non-serializable exceptions. Yes, it seems a
Producer problem, not a Consumer one, the embedded PlutoPortal component
is having problems setting your attribute on the session. Are you sure
your portlet is correctly exposed by WSRP4J Producer? Did you use the
new deploy webapp or deployed it manually?
Can you provide more details on your environment? JDK version,
OS, etc.
Regards.
Diego.