bowa
Jul 16th, 2007, 05:09 AM
I started from some code from
http://www.springframework.org/docs/reference/mvc.html#mvc-multipart
but when i want to copy the file i uploaded in the 'onSubmit' method of my FileUploadController (extending SimpleFormController) it looks from the log the CommonsMultipartResolver already cleaned up the multipart file ... it also seems strange the OpenSessionInViewInterceptor already closes the hibernate session ... while the controller is still working ?
16 jul 2007 10:48:40 DEBUG my.package.mvc.controller.FileUploadController - Creating new command of class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Getting BeanInfo for class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Caching PropertyDescriptors for class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Found bean property 'class' of type [java.lang.Class]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Found bean property 'file' of type [[B]
16 jul 2007 10:48:40 DEBUG org.springframework.core.CollectionFactory - Creating [java.util.LinkedHashMap]
16 jul 2007 10:48:40 DEBUG my.package.mvc.controller.FileUploadController - No errors -> processing submit
16 jul 2007 10:48:40 DEBUG org.springframework.core.CollectionFactory - Creating [java.util.LinkedHashMap]
16 jul 2007 10:48:40 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@1 4e1705] for key [org.hibernate.impl.SessionFactoryImpl@56ff18] from thread [http-8080-Processor24]
16 jul 2007 10:48:40 DEBUG org.springframework.orm.hibernate3.support.OpenSes sionInViewInterceptor - Closing single Hibernate Session in OpenSessionInViewInterceptor
16 jul 2007 10:48:40 DEBUG org.springframework.orm.hibernate3.SessionFactoryU tils - Closing Hibernate Session
16 jul 2007 10:48:40 DEBUG org.hibernate.impl.SessionImpl - closing session
16 jul 2007 10:48:40 DEBUG org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action
16 jul 2007 10:48:40 DEBUG org.springframework.web.multipart.commons.CommonsM ultipartResolver - Cleaning up multipart file [Filedata] with original filename [435148OIy.jpg], stored at [C:\projects\mywebapp\work\upload__1b6e95ee_113ce1b 37d7__7fff_00000000.tmp]
16 jul 2007 10:48:40 DEBUG org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@4b5abc
16 jul 2007 10:48:40 DEBUG org.springframework.web.servlet.DispatcherServlet - Could not complete request
java.lang.NullPointerException
at my.package.mvc.controller.FileUploadController.onS ubmit(FileUploadController.java:49)
at org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:267)
line 49 is where i get the original filename ...
code from my FileUploadController
MultipartHttpServletRequest multipartRequest =
(MultipartHttpServletRequest) request;
CommonsMultipartFile file =
(CommonsMultipartFile) multipartRequest.getFile("file");
String sep = System.getProperty("file.separator");
if (logger.isDebugEnabled()) {
logger.debug("uploading to: " + uploadDir + sep +
file.getOriginalFilename());
}
http://www.springframework.org/docs/reference/mvc.html#mvc-multipart
but when i want to copy the file i uploaded in the 'onSubmit' method of my FileUploadController (extending SimpleFormController) it looks from the log the CommonsMultipartResolver already cleaned up the multipart file ... it also seems strange the OpenSessionInViewInterceptor already closes the hibernate session ... while the controller is still working ?
16 jul 2007 10:48:40 DEBUG my.package.mvc.controller.FileUploadController - Creating new command of class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Getting BeanInfo for class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Caching PropertyDescriptors for class [my.package.document.FileUploadBean]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Found bean property 'class' of type [java.lang.Class]
16 jul 2007 10:48:40 DEBUG org.springframework.beans.CachedIntrospectionResul ts - Found bean property 'file' of type [[B]
16 jul 2007 10:48:40 DEBUG org.springframework.core.CollectionFactory - Creating [java.util.LinkedHashMap]
16 jul 2007 10:48:40 DEBUG my.package.mvc.controller.FileUploadController - No errors -> processing submit
16 jul 2007 10:48:40 DEBUG org.springframework.core.CollectionFactory - Creating [java.util.LinkedHashMap]
16 jul 2007 10:48:40 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@1 4e1705] for key [org.hibernate.impl.SessionFactoryImpl@56ff18] from thread [http-8080-Processor24]
16 jul 2007 10:48:40 DEBUG org.springframework.orm.hibernate3.support.OpenSes sionInViewInterceptor - Closing single Hibernate Session in OpenSessionInViewInterceptor
16 jul 2007 10:48:40 DEBUG org.springframework.orm.hibernate3.SessionFactoryU tils - Closing Hibernate Session
16 jul 2007 10:48:40 DEBUG org.hibernate.impl.SessionImpl - closing session
16 jul 2007 10:48:40 DEBUG org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action
16 jul 2007 10:48:40 DEBUG org.springframework.web.multipart.commons.CommonsM ultipartResolver - Cleaning up multipart file [Filedata] with original filename [435148OIy.jpg], stored at [C:\projects\mywebapp\work\upload__1b6e95ee_113ce1b 37d7__7fff_00000000.tmp]
16 jul 2007 10:48:40 DEBUG org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@4b5abc
16 jul 2007 10:48:40 DEBUG org.springframework.web.servlet.DispatcherServlet - Could not complete request
java.lang.NullPointerException
at my.package.mvc.controller.FileUploadController.onS ubmit(FileUploadController.java:49)
at org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:267)
line 49 is where i get the original filename ...
code from my FileUploadController
MultipartHttpServletRequest multipartRequest =
(MultipartHttpServletRequest) request;
CommonsMultipartFile file =
(CommonsMultipartFile) multipartRequest.getFile("file");
String sep = System.getProperty("file.separator");
if (logger.isDebugEnabled()) {
logger.debug("uploading to: " + uploadDir + sep +
file.getOriginalFilename());
}