File is not a normal file exception while using HttpClient()
[nobr]Hi All,
I would like to upload few files from the end user desktop machine to a unix server. This process will be done during the execution of a portal application (PAR). I was just trying my hands at the following code, but it gives me File is not a normal file exception.
****
publicvoid doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
response.write("Hi Sandip.....");
/** reading file informations */
final String serverURL ="serverURL";
PostMethod mPost=null;
try{
HttpClient httpCl =new HttpClient();
mPost =new PostMethod(serverURL);
File file1 =new File("D:\\JavaScreen.jpeg");
response.write("<BR>you selected the file::"+file1.getAbsolutePath());
mPost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,true);
response.write("<BR>Uploading file to server....");
//Part fileParts = new FilePart(file1.getName(),file1);
FilePart[] filePart ={
new FilePart(file1.getName(),file1)//add multiple files here
};
mPost.setRequestEntity(new MultipartRequestEntity(filePart,mPost.getParams()));
httpCl.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
int statusCode = httpCl.executeMethod(mPost);
if(statusCode==HttpStatus.SC_OK){
response.write("<BR>upload done:"+mPost.getResponseBodyAsString());
}else{
response.write("<BR>upload failed:"+HttpStatus.getStatusText(statusCode));
}
mPost.releaseConnection();
}catch (HttpException e){
// TODO Auto-generated catch block
//e.printStackTrace();
response.write("Excp1:"+e.getLocalizedMessage());
mPost.releaseConnection();
}catch (IOException e){
// TODO Auto-generated catch block
//e.printStackTrace()
response.write("Excp2:"+e.getLocalizedMessage());
response.write("Excp3::"+e.getCause());
mPost.releaseConnection();
}finally{
mPost.releaseConnection();
}
****
This is written inside a portal application. While running this code, it gives an output
Hi Sandip.....
you selected the file::D:\JavaScreen.jpeg
Uploading file to server....Excp2:File is not a normal file.Excp3::null
What could be the problem? I tried with 2-3 different files.
Would appreciate a reply.
Regards
Sandip Agarwal[/nobr]
Hi,
Here is the trace which I could get,
#0015600E7468007B0000002E00001CA00004358A1AC335F6#1184767177203#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###java.io.FileNotFoundException: File is not a normal file.#
#0015600E7468007B0000002F00001CA00004358A1AC33D26#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at org.apache.commons.httpclient.methods.multipart.FilePartSource.<init>(FilePartSource.java:68)#
#0015600E7468007B0000003000001CA00004358A1AC33D8E#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at org.apache.commons.httpclient.methods.multipart.FilePart.<init>(FilePart.java:129)#
#0015600E7468007B0000003100001CA00004358A1AC33DCA#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.nyt.test.vio.DisplayVio.doContent(DisplayVio.java:48)#
#0015600E7468007B0000003200001CA00004358A1AC33E02#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)#
#0015600E7468007B0000003300001CA00004358A1AC33E3C#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)#
#0015600E7468007B0000003400001CA00004358A1AC33E75#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)#
#0015600E7468007B0000003500001CA00004358A1AC33EBF#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)#
#0015600E7468007B0000003600001CA00004358A1AC33EF8#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)#
#0015600E7468007B0000003700001CA00004358A1AC33F31#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)#
#0015600E7468007B0000003800001CA00004358A1AC33F6A#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)#
#0015600E7468007B0000003900001CA00004358A1AC33FA2#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)#
#0015600E7468007B0000003A00001CA00004358A1AC33FDA#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)#
#0015600E7468007B0000003B00001CA00004358A1AC34013#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)#
#0015600E7468007B0000003C00001CA00004358A1AC34052#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)#
#0015600E7468007B0000003D00001CA00004358A1AC3408C#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)#
#0015600E7468007B0000003E00001CA00004358A1AC340C5#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)#
#0015600E7468007B0000003F00001CA00004358A1AC340FB#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at java.security.AccessController.doPrivileged(Native Method)#
#0015600E7468007B0000004000001CA00004358A1AC34132#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)#
#0015600E7468007B0000004100001CA00004358A1AC3416E#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)#
#0015600E7468007B0000004200001CA00004358A1AC341A7#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)#
#0015600E7468007B0000004300001CA00004358A1AC341E0#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)#
#0015600E7468007B0000004400001CA00004358A1AC34217#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)#
#0015600E7468007B0000004500001CA00004358A1AC34250#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)#
#0015600E7468007B0000004600001CA00004358A1AC34289#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)#
#0015600E7468007B0000004700001CA00004358A1AC342C1#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)#
#0015600E7468007B0000004800001CA00004358A1AC342FA#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)#
#0015600E7468007B0000004900001CA00004358A1AC34332#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)#
#0015600E7468007B0000004A00001CA00004358A1AC3436A#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)#
#0015600E7468007B0000004B00001CA00004358A1AC343A2#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)#
#0015600E7468007B0000004C00001CA00004358A1AC343DB#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)#
#0015600E7468007B0000004D00001CA00004358A1AC34419#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)#
#0015600E7468007B0000004E00001CA00004358A1AC34451#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)#
#0015600E7468007B0000004F00001CA00004358A1AC34487#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at java.security.AccessController.doPrivileged(Native Method)#
#0015600E7468007B0000005000001CA00004358A1AC344BE#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)#
#0015600E7468007B0000005100001CA00004358A1AC344F5#1184767177218#System.err#sap.com/irj#System.err#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#1e33d8e0353711dca4d00015600e7468#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)#
#0015600E7468007F0000000700001CA00004358A1CA4149B#1184767209125#com.sap.portal.portal#sap.com/irj#com.sap.portal.portal#AGARWS#1539##nyt45hq45epd1_EPD_18053950#AGARWS#23add320353711dc92470015600e7468#Thread[PRT-Async 3,5,PRT-Async]##0#0#Error#1#/System/Server#Java###Operation failed ..
Regards
Sandip
I get a similar exception using commons-httpclient-2.0.2 but I noticed that this exception occurs only when I test my strus web-application whith Mozilla, I mean with IE7 I do not have this problem. So any of you have any idea?
Here is my trace 10x
java.io.FileNotFoundException: File is not a normal file.
at org.apache.commons.httpclient.methods.multipart.FilePartSource.<init>(FilePartSource.java:70)
at org.apache.commons.httpclient.methods.multipart.FilePart.<init>(FilePart.java:131)
at org.apache.commons.httpclient.methods.MultipartPostMethod.addParameter(MultipartPostMethod.java:168)
at app.action.fileup.HTTPsendFile.queryServerFile(HTTPsendFile.java:79)
at app.action.fileup.DocumentsUploadServlet.doPost(DocumentsUploadServlet.java:151)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
CbKa at 2007-7-29 12:04:22 >
