[javax.portlet.RenderRequest] resolved to incompatible value of type ..
I encounter this problem during my portlet development and spend quite sometime to figure out the root cause and solutions.
-
Caused by: java.lang.IllegalStateException:
-
-
Standard argument type [javax.portlet.RenderRequest] resolved to incompatible value of type [class com.liferay.portlet.ActionRequestImpl]. Consider declaring the argument type in a less specific fashion.
-
at org….resolveCommonArgument(HandlerMethodInvoker.java:849)
-
at org….resolveHandlerArguments(HandlerMethodInvoker.java:298)
-
at org….invokeHandlerMethod(HandlerMethodInvoker.java:151)
-
… 176 more
-
|#]
-
-
[#|2010-07-16T13:27:44.296+0800|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=19;_ThreadName=httpSSLWorkerThread-8080-1;|13:27:44,296 ERROR [jsp:164] java.lang.IllegalStateException: Standard argument type [javax.portlet.RenderRequest] resolved to incompatible value of type [class com.liferay.portlet.ActionRequestImpl]. Consider declaring the argument type in a less specific fashion.
-
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:80)
-
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:56)
-
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
-
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
-
-
|#]
Sample Code
-
-
@Controller
-
@RequestMapping("EDIT")
-
public class ConfigurationController {
-
@Autowired private PortletPreferencesService service;
-
-
@RenderMapping
-
return "configuration";
-
}
-
-
@ActionMapping
-
public void doPost(@ModelAttribute(value = "config") PortletPreferences preferences,
-
ActionRequest request, ActionResponse response) {
-
//…do something
-
}
-
-
@ModelAttribute("config")
-
public PortletPreferences getPortletPreferences(RenderRequest request) {
-
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
-
long plid = themeDisplay.getScopeGroupId();
-
return service.getPortletPreferences(plid, portletId);
-
}
-
-
}
-
Explain:
From the above sample code, it will first load the @ModelAttribute(“config”) before any others method. Therefore, the RenderRequest is still valid object. But once you click the submit or link from your jsp for ActionResponse.
It will load again @ModelAttribute(“config”), but this time the PortletRequest is instance of “Action” type, so spring will throws the exception into console or log file like “[javax.portlet.RenderRequest] resolved to incompatible value of type [class com.liferay.portlet.ActionRequestImpl].”
Workaround :
Remember never apply RenderRequest in your @ModelAttribute directly, you can choose to use @RequestParam(“id”) String id, instead of the RenderRequest to avoid the incompatible error.

Posted in 


