Announcement Announcement Module
Collapse
No announcement yet.
NoSuchMethodError portlet.FlowHandlerAdapter.checkAndPrepare Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoSuchMethodError portlet.FlowHandlerAdapter.checkAndPrepare

    I am using SWF, for some reason i need to update my project dependencies to spring from 2.5.6 to 3.0.1.
    SWF is still 2.0.8, but i tried also with 2.0.7
    My apps are portlet... is 3.0 compatible with webflow?

    I get this error:
    Error rendering portlet.

    javax.portlet.PortletException: Error occured during request processing: org.springframework.webflow.mvc.portlet.FlowHandle rAdapter.checkAndPrepare(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponseV
    at org.springframework.web.portlet.DispatcherPortlet. doRenderService(DispatcherPortlet.java:781)
    at org.springframework.web.portlet.FrameworkPortlet.p rocessRequest(FrameworkPortlet.java:522)
    at org.springframework.web.portlet.FrameworkPortlet.d oDispatch(FrameworkPortlet.java:470)
    at javax.portlet.GenericPortlet.render(GenericPortlet .java:253)
    at org.apache.pluto.driver.services.container.FilterC hainImpl.doFilter(FilterChainImpl.java:163)
    at org.apache.pluto.driver.services.container.FilterC hainImpl.processFilter(FilterChainImpl.java:91)
    at org.apache.pluto.driver.services.container.FilterM anagerImpl.processFilter(FilterManagerImpl.java:10 5)
    at org.apache.pluto.container.driver.PortletServlet.d ispatch(PortletServlet.java:340)
    at org.apache.pluto.container.driver.PortletServlet.d oGet(PortletServlet.java:261)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.doI nclude(ApplicationDispatcher.java:535)
    at org.apache.catalina.core.ApplicationDispatcher.inc lude(ApplicationDispatcher.java:472)
    at org.apache.pluto.driver.container.DefaultPortletIn vokerService.invoke(DefaultPortletInvokerService.j ava:233)
    at org.apache.pluto.driver.container.DefaultPortletIn vokerService.render(DefaultPortletInvokerService.j ava:117)
    at org.apache.pluto.container.impl.PortletContainerIm pl.doRender(PortletContainerImpl.java:157)
    at org.apache.pluto.driver.tags.PortletTag.doStartTag (PortletTag.java:148)
    at org.apache.jsp.WEB_002dINF.themes.portlet_002dskin _jsp._jspService(portlet_002dskin_jsp.java:85)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.doI nclude(ApplicationDispatcher.java:535)
    at org.apache.catalina.core.ApplicationDispatcher.inc lude(ApplicationDispatcher.java:472)
    at org.apache.jasper.runtime.JspRuntimeLibrary.includ e(JspRuntimeLibrary.java:968)
    at org.apache.jsp.WEB_002dINF.themes.pluto_002ddefaul t_002dtheme_jsp._jspx_meth_c_005fforEach_005f1(plu to_002ddefault_002dtheme_jsp.java:521)
    at org.apache.jsp.WEB_002dINF.themes.pluto_002ddefaul t_002dtheme_jsp._jspx_meth_c_005fotherwise_005f0(p luto_002ddefault_002dtheme_jsp.java:465)
    at org.apache.jsp.WEB_002dINF.themes.pluto_002ddefaul t_002dtheme_jsp._jspx_meth_c_005fchoose_005f0(plut o_002ddefault_002dtheme_jsp.java:326)
    at org.apache.jsp.WEB_002dINF.themes.pluto_002ddefaul t_002dtheme_jsp._jspService(pluto_002ddefault_002d theme_jsp.java:162)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:302)
    at org.apache.pluto.driver.PortalDriverServlet.doGet( PortalDriverServlet.java:189)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:525)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoSuchMethodError: org.springframework.webflow.mvc.portlet.FlowHandle rAdapter.checkAndPrepare(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponseV
    at org.springframework.webflow.mvc.portlet.FlowHandle rAdapter.handleRender(FlowHandlerAdapter.java:117)
    at org.springframework.web.portlet.DispatcherPortlet. doRenderService(DispatcherPortlet.java:740)
    ... 64 more

  • #2
    I don't know specifics, but even though some people have been able to get SWF 2 working with Spring 3, they aren't designed to work together. Some functionality is unavailable.

    SWF 3 is specifically designed to work with Spring 3. You might want to check the JIRA. The team should be close to the first milestone release.

    Comment


    • #3
      Hi there,

      I know its dirty, but I worked around this issue by making my own CustomFlowHandlerAdapter. I Just copied the source and did some adjustments(changing imports). Notice those two methodes that are not implemented yet at the bottom. I'm sure that handles portlet 2.0 features (which i'm not using). The PorletContentGenerator and FlowHandler are classes from spring 3.0.

      Code:
      package com.xxxxx.web.webflow.adapter;
      
      import java.io.IOException;
      import java.util.Iterator;
      import java.util.Map;
      
      import javax.portlet.ActionRequest;
      import javax.portlet.ActionResponse;
      import javax.portlet.EventRequest;
      import javax.portlet.EventResponse;
      import javax.portlet.PortletModeException;
      import javax.portlet.PortletRequest;
      import javax.portlet.PortletResponse;
      import javax.portlet.PortletSession;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      import javax.portlet.ResourceRequest;
      import javax.portlet.ResourceResponse;
      
      import org.springframework.beans.factory.InitializingBean;
      import org.springframework.util.Assert;
      import org.springframework.web.portlet.HandlerAdapter;
      import org.springframework.web.portlet.ModelAndView;
      import org.springframework.web.portlet.handler.PortletContentGenerator;
      import org.springframework.webflow.context.portlet.DefaultFlowUrlHandler;
      import org.springframework.webflow.context.portlet.FlowUrlHandler;
      import org.springframework.webflow.context.portlet.PortletExternalContext;
      import org.springframework.webflow.core.FlowException;
      import org.springframework.webflow.core.collection.LocalAttributeMap;
      import org.springframework.webflow.core.collection.MutableAttributeMap;
      import org.springframework.webflow.execution.FlowExecutionOutcome;
      import org.springframework.webflow.execution.repository.NoSuchFlowExecutionException;
      import org.springframework.webflow.executor.FlowExecutionResult;
      import org.springframework.webflow.executor.FlowExecutor;
      import org.springframework.webflow.mvc.portlet.FlowHandler;
      
      /**
       * A custom MVC HandlerAdapter that encapsulates the generic workflow associated with executing flows in a Portlet
       * environment. Delegates to mapped {@link FlowHandler flow handlers} to manage the interaction with executions of
       * specific flow definitions.
       * 
       * @author Keith Donald
       * @author Scott Andrews
       */
      public class CustomFlowHandlerAdapter extends PortletContentGenerator implements HandlerAdapter, InitializingBean {
      
      	private static final String ACTION_REQUEST_FLOW_EXCEPTION_ATTRIBUTE = "actionRequestFlowException";
      
      	private FlowExecutor flowExecutor;
      
      	private FlowUrlHandler flowUrlHandler;
      
      	/**
      	 * Creates a new flow handler adapter.
      	 * @see #setFlowExecutor(FlowExecutor)
      	 * @see #setFlowUrlHandler(FlowUrlHandler)
      	 * @see #afterPropertiesSet()
      	 */
      	public CustomFlowHandlerAdapter() {
      		// prevent caching of flow pages by default
      		setCacheSeconds(0);
      	}
      
      	/**
      	 * Returns the central service for executing flows. Required.
      	 */
      	public FlowExecutor getFlowExecutor() {
      		return flowExecutor;
      	}
      
      	/**
      	 * Sets the central service for executing flows. Required.
      	 * @param flowExecutor
      	 */
      	public void setFlowExecutor(FlowExecutor flowExecutor) {
      		this.flowExecutor = flowExecutor;
      	}
      
      	/**
      	 * Returns the flow url handler.
      	 */
      	public FlowUrlHandler getFlowUrlHandler() {
      		return flowUrlHandler;
      	}
      
      	/**
      	 * Sets the flow url handler
      	 * @param urlHandler the flow url handler
      	 */
      	public void setFlowUrlHandler(FlowUrlHandler urlHandler) {
      		this.flowUrlHandler = urlHandler;
      	}
      
      	public void afterPropertiesSet() throws Exception {
      		Assert.notNull(flowExecutor, "The FlowExecutor to execute flows is required");
      		if (flowUrlHandler == null) {
      			flowUrlHandler = new DefaultFlowUrlHandler();
      		}
      	}
      
      	public boolean supports(Object handler) {
      		return handler instanceof FlowHandler;
      	}
      
      	public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception {
      		FlowHandler flowHandler = (FlowHandler) handler;
      		checkAndPrepare(request, response);
      		populateConveniencePortletProperties(request);
      		PortletSession session = request.getPortletSession(false);
      		if (session != null) {
      			FlowException e = (FlowException) session.getAttribute(ACTION_REQUEST_FLOW_EXCEPTION_ATTRIBUTE);
      			if (e != null) {
      				session.removeAttribute(ACTION_REQUEST_FLOW_EXCEPTION_ATTRIBUTE);
      				return handleException(e, flowHandler, request, response);
      			}
      		}
      		String flowExecutionKey = flowUrlHandler.getFlowExecutionKey(request);
      		if (flowExecutionKey != null) {
      			return resumeFlow(flowExecutionKey, flowHandler, request, response);
      		} else {
      			return startFlow(flowHandler, request, response);
      		}
      	}
      
      	public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception {
      		FlowHandler flowHandler = (FlowHandler) handler;
      		populateConveniencePortletProperties(request);
      		String flowExecutionKey = flowUrlHandler.getFlowExecutionKey(request);
      		PortletExternalContext context = createPortletExternalContext(request, response);
      		try {
      			FlowExecutionResult result = flowExecutor.resumeExecution(flowExecutionKey, context);
      			if (result.isPaused()) {
      				flowUrlHandler.setFlowExecutionRenderParameter(result.getPausedKey(), response);
      			} else if (result.isEnded()) {
      				handleFlowExecutionOutcome(result.getOutcome(), flowHandler, request, response);
      			} else {
      				throw new IllegalStateException("Execution result should have been one of [paused] or [ended]");
      			}
      		} catch (FlowException e) {
      			request.getPortletSession().setAttribute(ACTION_REQUEST_FLOW_EXCEPTION_ATTRIBUTE, e);
      		}
      	}
      
      	// subclassing hooks
      
      	protected void populateConveniencePortletProperties(PortletRequest request) {
      		request.setAttribute("portletMode", request.getPortletMode().toString());
      		request.setAttribute("portletWindowState", request.getWindowState().toString());
      	}
      
      	protected PortletExternalContext createPortletExternalContext(PortletRequest request, PortletResponse response) {
      		return new PortletExternalContext(getPortletContext(), request, response);
      	}
      
      	protected MutableAttributeMap defaultCreateFlowExecutionInputMap(PortletRequest request) {
      		Map parameterMap = request.getParameterMap();
      		if (parameterMap.size() == 0) {
      			return null;
      		}
      		LocalAttributeMap inputMap = new LocalAttributeMap();
      		Iterator it = parameterMap.entrySet().iterator();
      		while (it.hasNext()) {
      			Map.Entry entry = (Map.Entry) it.next();
      			String name = (String) entry.getKey();
      			String[] values = (String[]) entry.getValue();
      			if (values.length == 1) {
      				inputMap.put(name, values[0]);
      			} else {
      				inputMap.put(name, values);
      			}
      		}
      		return inputMap;
      	}
      
      	protected void defaultHandleExecutionOutcome(FlowExecutionOutcome outcome, FlowHandler flowHandler,
      			ActionRequest request, ActionResponse response) throws PortletModeException {
      	}
      
      	protected ModelAndView defaultHandleException(FlowHandler flowHandler, FlowException e, RenderRequest request,
      			RenderResponse response) {
      		if (e instanceof NoSuchFlowExecutionException) {
      			if (logger.isDebugEnabled()) {
      				logger.debug("Restarting a new execution of previously ended flow '" + flowHandler.getFlowId() + "'");
      			}
      			// by default, attempt to restart the flow
      			startFlow(flowHandler, null, request, response);
      			return null;
      		} else {
      			throw e;
      		}
      	}
      
      	// helpers
      
      	private ModelAndView handleException(FlowException e, FlowHandler flowHandler, RenderRequest request,
      			RenderResponse response) {
      		String viewName = flowHandler.handleException(e, request, response);
      		if (viewName != null) {
      			return new ModelAndView(viewName);
      		} else {
      			return defaultHandleException(flowHandler, e, request, response);
      		}
      	}
      
      	private void handleFlowExecutionOutcome(FlowExecutionOutcome outcome, FlowHandler flowHandler,
      			ActionRequest request, ActionResponse response) throws PortletModeException {
      		boolean handled = flowHandler.handleExecutionOutcome(outcome, request, response);
      		if (!handled) {
      			defaultHandleExecutionOutcome(outcome, flowHandler, request, response);
      		}
      	}
      
      	private ModelAndView startFlow(FlowHandler flowHandler, RenderRequest request, RenderResponse response) {
      		MutableAttributeMap input = flowHandler.createExecutionInputMap(request);
      		if (input == null) {
      			input = defaultCreateFlowExecutionInputMap(request);
      		}
      		return startFlow(flowHandler, input, request, response);
      	}
      
      	private ModelAndView startFlow(FlowHandler flowHandler, MutableAttributeMap input, RenderRequest request,
      			RenderResponse response) {
      		PortletExternalContext context = createPortletExternalContext(request, response);
      		try {
      			FlowExecutionResult result = flowExecutor.launchExecution(flowHandler.getFlowId(), input, context);
      			if (result.isPaused()) {
      				flowUrlHandler.setFlowExecutionInSession(result.getPausedKey(), request);
      			}
      			return null;
      		} catch (FlowException e) {
      			return handleException(e, flowHandler, request, response);
      		}
      	}
      
      	private ModelAndView resumeFlow(String flowExecutionKey, FlowHandler flowHandler, RenderRequest request,
      			RenderResponse response) throws IOException {
      		PortletExternalContext context = createPortletExternalContext(request, response);
      		try {
      			flowExecutor.resumeExecution(flowExecutionKey, context);
      			return null;
      		} catch (FlowException e) {
      			return handleException(e, flowHandler, request, response);
      		}
      	}
      
      	public void handleEvent(EventRequest request, EventResponse response,
      			Object handler) throws Exception {
      		// TODO Auto-generated method stub
      		
      	}
      
      	public ModelAndView handleResource(ResourceRequest request,
      			ResourceResponse response, Object handler) throws Exception {
      		// TODO Auto-generated method stub
      		return null;
      	}
      
      }

      Comment


      • #4
        Thanks

        Thanks for answering,
        Finally, i will wait for the SWF 3.0

        Comment


        • #5
          If you are in the position to wait I certainly recommend that...

          Regards,

          Marc

          Comment


          • #6
            @epsilon777

            Do you know the timeline for SWF 3.0? I can't find it and the project looks if its in a deep sleep...

            Comment


            • #7
              swf 3

              On the jira page of swf, it seems that the first milestone should be available in march (the 17th), but i have no more info

              Comment


              • #8
                Okay..thanks!

                Comment

                Working...
                X