Forums de discussion

CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.2

KARTHIK SUNDARAM, modifié il y a 12 années.

CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.2

New Member Publications: 4 Date d'inscription: 14/05/11 Publications récentes
Hi,

I am new to Liferay and this forum. I am using Spring 2.5 Portlet MVC framework on Liferay 5.2.2. I have a functionality to upload a file in my portlet. I have given the following code in my xml file.

<bean id="portletMultipartResolver" class= "org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
<property name="maxUploadSize" value="100000" />
</bean>

I have also added the necessary apache commons jar files (commons-fileupload & commons-io) in my WAR.

I do have enctype="multipart/form-data" in my JSP. When I submit the form after selecting the file I am getting the the form parameters and the file in my controller. However I am getting the following error when I try to use the incoming ActionRequest to get the logged in UserId using PortalUtil.getUserId(request) method.

13:43:30,804 WARN [DispatcherPortlet:998] Handler execution resulted in excepti
on - forwarding to resolved error view
java.lang.RuntimeException: Unable to get the HTTP servlet request from org.springframework.web.portlet.multipart.DefaultMultipartActionRequest
at com.liferay.portal.util.PortalImpl.getHttpServletRequest(PortalImpl.java:916)
at com.liferay.portal.util.PortalImpl.getUserId(PortalImpl.java:2436)
at com.liferay.portal.util.PortalUtil.getUserId(PortalUtil.java:722)
at com.minacs.link.controller.InsertController.onSubmitAction(InsertController.java:73)


During debugging I found that the incoming action request object is instance of class org.springframework.web.portlet.multipart.DefaultMultipartActionRequest

When I comment out enctype and my file upload in my JSP and submit the page everything works fine. This time the incoming ActionRequest is of type com.liferay.portlet.ActionRequestImpl.

Seems like during file upload, Spring encapsulates the incoming ActionRequest object to DefaultMultiPartActionRequest. However, when Liferay tries to get the underlying HttpServletRequest during the operation of getUserId it failes and throws the error "Unable to get the HTTP servlet reques".

When I checked the source code of Liferay 5.2.2 for the method PortalImpl.getHttpServletRequest(request) method checks if the incoming request is instance of PortletRequestImpl. Due to some reason when I place the following code in my controller
_log.info("inside onSubmitAction..." + (request instanceof org.springframework.web.portlet.multipart.DefaultMultipartActionRequest));
_log.info("inside onSubmitAction..." + (request instanceof javax.portlet.PortletRequest));
_log.info("inside onSubmitAction..." + (request instanceof com.sun.portal.portletcontainer.portlet.impl.PortletRequestImpl));

it returns true, true & FALSE. Since the PortletImpl.getHttpServletRequest checks for the incoming request to be instance of com.sun.portal.portletcontainer.portlet.impl.PortletRequestImpl returns false, it finally returns NULL for HttpServletRequest and the above Runtime Exception is thrown.

I am not sure how to proceed further and stuck at this roadblock and not able to continue my functionality. Any help or direction is much appreciated.

Thanks
Kay
thumbnail
Mika Koivisto, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
Are you by any change using sun container? If you are try switching it back to Liferays own container.
Kay Sun, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

New Member Publications: 4 Date d'inscription: 14/05/11 Publications récentes
Hi,

I am using Tomcat 6 with Liferay 5.2.2. Let me know if that is causing any issue?

Thanks
Kay
thumbnail
Mika Koivisto, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
Is your portlet.container.impl property set to internal or sun? If it's set to sun set it to internal and try again.
Kay Sun, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

New Member Publications: 4 Date d'inscription: 14/05/11 Publications récentes
Thanks for the input!

Tried the same but no luck! emoticon
thumbnail
Mika Koivisto, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
I've used Spring Portlet MVC in the past successfully so it might be some bug in your particular Liferay version. Can you try to deploy your plugin to the most recent CE (6.0.6) to see if you get the same error.
Kay Sun, modifié il y a 12 années.

RE: CommonsPortletMultipartResolver (Spring 2.5 portlet MVC) + Liferay 5.2.

New Member Publications: 4 Date d'inscription: 14/05/11 Publications récentes
I tried my plugin using 6.0.2 but now the error is "Unable to get HTTP request". Will there be any issues with cglib jar files that I am including. Is it possible to get the list of jar files required for Spring Portlet MVC with commons file upload?

Thanks for all of your suggestions!