FAQ
Hi,

I tried a POC using Camel 2.8.0 and now am not getting error "500 Internal Server Error". But the error at the tomcat server side still persists.

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

Here is the FileUpload.jsp which I am using to upload the file.

<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Process File Upload</title>
</head>
<%

System.out.println("Content Type ="+request.getContentType());

DiskFileUpload fu = new DiskFileUpload();
// If file size exceeds, a FileUploadException will be thrown
fu.setSizeMax(1000000);

List fileItems = fu.parseRequest(request);
System.out.println("List of files ="+request.getContentType());
Iterator itr = fileItems.iterator();

while(itr.hasNext()) {
FileItem fi = (FileItem)itr.next();

//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {
System.out.println("nNAME: "+fi.getName());
System.out.println("SIZE: "+fi.getSize());
//System.out.println(fi.getOutputStream().toString());
File fNew= new File(application.getRealPath("/"), fi.getName());

System.out.println(fNew.getAbsolutePath());
fi.write(fNew);
}
else {
System.out.println("Field ="+fi.getFieldName());
}
}
%>
<body>
Upload Successful!!
</body>
</html>

I read somewhere that camel-http internally uses the apache commons httplient api.
I tried it without camel and it works fine and same JSP is able to upload the file.


Code without using camel :

public class MultipartFileUpload {
private static String url =
"http://localhost/displaytag-examples-1.2/ProcessFileUpload.jsp";

@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException {
HttpClient client = new HttpClient();

MultipartPostMethod mPost = new MultipartPostMethod(url);

client.setConnectionTimeout(8000);

File f1 = new File("test.xml");

mPost.addParameter(f1.getName(), f1);

int statusCode1 = client.executeMethod(mPost);

mPost.getParams().setParameter(HttpMethodParams.USE_EXPECT_CONTINUE,true);
mPost.releaseConnection();
}
}



Thank you.

Regards,
Shadab










-----Original Message-----
From: Claus Ibsen
Sent: Friday, October 14, 2011 4:09 PM
To: users@camel.apache.org
Subject: Re: Need help with Camel http producer

Hi

Are you really using Camel 2.0.0 ? This is a very old release.

The camel-http component have been improved so it detects if you pickup files, and upload that using the File support from the Http Client framework.

So if possible I suggest to try to consider upgrading Camel.

On Thu, Oct 13, 2011 at 3:58 PM, Mohammad Shadab Ali wrote:
Hi,

I tried to upload the files using apache commons httpclient and FileUpload api as multipart POSTs and it was successful. But the same thing when I tried using camel routes I am getting exception at both sides server and client.
I am getting the following exceptions:

1. At client side :

SEVERE: HTTP operation failed with statusCode: 500, status: HTTP/1.1
500 Internal Server Error
org.apache.camel.component.http.HttpOperationFailedException: HTTP
operation failed with statusCode: 500, status: HTTP/1.1 500 Internal
Server Error
at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFail
edException(HttpProducer.java:141)
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java
:89)
at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.
java:81)
at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.
java:79)
at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:14
1)
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:78
)
at
org.apache.camel.management.InstrumentationProcessor.process(Instrumen
tationProcessor.java:61)
at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(Rede
liveryErrorHandler.java:186)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
java:907)
at java.lang.Thread.run(Thread.java:619)
Oct 13, 2011 5:50:26 PM
org.apache.camel.component.file.GenericFileOnCompletion
processStrategyRollback
WARNING: Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrateg
y@1632847 for file: GenericFile[academy.xml] Oct 13, 2011 5:50:26 PM
org.apache.camel.processor.Logger log



2. At server side :

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.commons.fileupload.FileUploadException: the request was
rejected because no multipart boundary was found
at
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBa
se.java:327)
at
org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp
.java:78)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.
java:377)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:31
3)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)



3. I am using the below camel route to upload the file.


from("file:inbox?noop=true").setHeader(Exchange.HTTP_METHOD,
constant(org.apache.camel.component.http.HttpMethods.POST))

.setHeader(Exchange.CONTENT_TYPE, constant("multipart/form-data"))
.to("http://10.200.41.29:8082/displaytag-examples-1.2/ProcessFileUploa
d.jsp");

Has anyone else seen this or have any ideas on how to get around this issue?


Thank you.

Regards,
Shadab


















-----Original Message-----
From: Willem Jiang
Sent: Tuesday, October 11, 2011 12:28 PM
To: users@camel.apache.org
Subject: Re: Need help with Camel http producer

Did you check the service log which works listen to "http://localhost:8080/myServer/" ?
On Tue Oct 11 14:40:46 2011, Mohammad Shadab Ali wrote:
Hi,


1. I am new with Camel. I am trying to create route as to process file from a file component and pass on to a http tomcat server through http producer, but I am not able to upload the file to the server.

2. I have created the route as follows

from("file:inbox?noop=false").to("http://localhost:8080/myServer/");

I have also tried using my I.P address in place of localhost


3. I am not getting any compilation error nor at runtime and the file is getting processed from inbox folder, but I am not able to receive the file in myServer directory.

4. Camel version I am using is 2.0.0 .


Thanks& regards,
Shadab


________________________________
***The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review,retransmission,dissemination or other
use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete
the material from any computer.***


--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang


***The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review,retransmission,dissemination or other
use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete
the material from any computer.***


--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

***The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review,retransmission,dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.***

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 7 | next ›
Discussion Overview
groupusers @
categoriescamel
postedOct 11, '11 at 6:41a
activeOct 24, '11 at 8:20a
posts7
users3
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase