I am trying to develop an application where user will upload a file from screen, the file will be processed in server side.
I am using Adobe Flex for UI, Spring 3.2 as middleware and Java 5. I can successfully upload the file and in server side can get the file name. But when I am trying to get the InputStream, get FileNotFoundException. It seams it is trying to create a temporary file in some location inside the application server and trying to read that temporary file for processing, but failed to create the temporary file. Following is the code snippet where I tries to get the file -
public List<TransactionVO> populateVO(VoucherUploadCommandForm object,
Connection conn) throws XenosException {
log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> In VoucherVOPopulatorForExcelUpload.populateVO()");
if(object == null){
log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> No file uploaded :(");
}else{
CommonsMultipartFile file = object.getFileName();
log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Excel file uploaded :)");
log.debug("Excel file= "+ file.getOriginalFilename());
try {
log.debug("Excel Size= "+ file.getSize());
log.debug("Excel fileItem= "+ file.getFileItem().getInputStream());
} catch (IOException e) {
log.error(e);
}
}
return null;
}
The stackTrace of the error is as follows -
SEVERE: Exception loading sessions from persistent storage
java.io.FileNotFoundException: C:\apache-tomcat-6.0.20\work\Catalina\localhost\rui-1.1-xenos\upload_375f4172_d416_4ae2_975f_bc5e908a8303_00000007.tmp (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.apache.commons.fileupload.disk.DiskFileItem.readObject(DiskFileItem.java:663)
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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1441)
at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:942)
at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394)
at org.apache.catalina.session.StandardManager.load(StandardManager.java:321)
at org.apache.catalina.session.StandardManager.start(StandardManager.java:637)
at org.apache.catalina.core.ContainerBase.setManager(ContainerBase.java:438)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4358)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Nov 25, 2013 2:56:18 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8084
Nov 25, 2013 2:56:18 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Nov 25, 2013 2:56:18 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/20 config=null
Nov 25, 2013 2:56:18 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 45220 ms