users@jersey.java.net

Re: [Jersey] Jersey, Jmeter and multipart

From: EZZAT Mani <mani.ezzat_at_neuf.fr>
Date: Fri, 24 Sep 2010 18:34:47 +0200

Hi Paul and thanks for your answer.

Here's the request log sent by Jmeter :

Accept-Language: fr,en;q=0.8,fr-fr;q=0.5,en-us;q=0.3
Content-Length: 7716
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip,deflate
Keep-Alive: 115
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0E)
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type: multipart/form-data;
boundary=---------------------------7d159c1302d0y0
----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="charset"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
UTF-8
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="config"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
lr.basic.entity
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="profile"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
default
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="lng"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
fr
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="echo"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
all
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="entities"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
Person
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="relations"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
 
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="extraction.mode"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
tree
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="pipe"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
fr_full
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="terms"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
 
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.entities.atts"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
true
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.relations.atts"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
true
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.labels.lng"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
fr
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.labels"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
true
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.occs.position"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
true
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="f.occs.text"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
 
true
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="file"; filename="HstapplyTexteLIGHT.txt"
Content-Type: text/plain
Content-Transfer-Encoding: binary
 
<actual file content, not shown here>
-----------------------------7d159c1302d0y0--
 via a browser or using a java client (which use
Jersey), there isn't the content-transfer-encoding 8 bits for string param,
nor binary for the file param

Here is the trace :

b>java.lang.IllegalStateException: Media type is not text/plain</b><br/>
com.sun.jersey.multipart.FormDataBodyPart.getValue(FormDataBodyPart.java:279)<br/>
com.arisem.eidon.server.MultiPartFormReader.retrieveValue(MultiPartFormReader.java:198)<br/>
com.arisem.eidon.server.finder.RequestParser.checkConfiguration(RequestParser.java:261)<br/>
com.arisem.eidon.server.finder.RequestParser.checkParameters(RequestParser.java:236)<br/>
com.arisem.eidon.server.finder.EntityFinderResource.postForm(EntityFinderResource.java:129)<br/>
sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)<br/>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>
java.lang.reflect.Method.invoke(Method.java:597)<br/>
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:175)<br/>
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)<br/>
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:166)<br/>
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:74)<br/>
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:114)<br/>
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:66)<br/>
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:709)<br/>
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:667)<br/>
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:658)<br/>
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:318)<br/>
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)<br/>
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:604)<br/>
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)<br/>
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)<br/>
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)<br/>
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)<br/>
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)<br/>
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)<br/>
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)<br/>
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)<br/>
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)<br/>
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)<br/>
org.mortbay.jetty.Server.handle(Server.java:326)<br/>
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)<br/>
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)<br/>
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)<br/>
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)<br/>
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)<br/>
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)<br/>
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)<br/>
3 September 2010 18:59:12 Paul Sandoz wrote:
> Hi,
>
> Can you enable logging:
>
>
> https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api
> /container/filter/LoggingFilter.html
>
> and email the log from the server, from when Jersey initiates up to
> and including when it responds with an error for the multipart/form-
> data request from JMeter.
>
> I want to see the exact request that JMeter is sending so i can
> determine if this is an issue with the Jersey multipart processing.
> The error indicates that the part you are accessing declares a media
> type other than text/plain.
>
> Paul.
>
> On Sep 23, 2010, at 3:50 AM, EZZAT Mani wrote:
> > Sorry to insist again :-(
> > Spent the last few days trying to solve this, but I can't make it
> > work :(
> > Does anyone have an idea ?
> >
> > On Monday 20 September 2010 21:22:36 mani.ezzat_at_neuf.fr wrote:
> >> Hello,
> >>
> >> I've got a problem but i'm not sure it's a jersey problem.
> >>
> >> I've got a webapp using Jersey. Server side, i have two methods.
> >> One for
> >> url encoded request, and an other for a file AND the same
> >> parameters of
> >> the url encoded one.
> >>
> >> My problem is concerning the second method (a POST)
> >> I use a multipart/form mediaType with a field named "file"
> >> containing the
> >> uploaded file. The other fields are string param
> >>
> >> When I use a browser everything is fine. Same if I use a java
> >> client (which
> >> use Jersey)
> >>
> >> But when I use Jmeter i've got an Exception.
> >> I'm not at work so i can't past it. But it's about the getValue
> >> method of
> >> the bodypart class. It says thats the content must be text/plain
> >> (like
> >> written in the javadoc)
> >>
> >> I looked at the request done by Jmeter and by a browser.
> >> It's the same except for one thing :
> >> Jmeter sends a content-transfer-encoding: 8 bits for each field of
> >> the
> >> multipart form, and binary for the file.
> >>
> >> I can't change that behaviour in Jmeter. According to some RFC
> >> specif,
> >> Jmeter seems to be right. My question is : is this really a Jersey
> >> thing ?
> >> and how can I make my app (server side) handle those requests ? I
> >> tried
> >> getEntityAs and getValueAs and i got another exception which says
> >> that de
> >> content isn't the unconverted entity (as writter in the javadoc too)
> >>
> >> To make it "simple", I have server side a method like this :
> >>
> >> @consume "multipart/form"
> >> getform(FormDataMultipart form){
> >> form.getField("my param").getValue()
> >> }
> >> and it sends the text/plain exception on getvalue (only if it's a
> >> jmeter
> >> request)
> >>
> >> I'm using jersey 1.1.1 (i have also the multipart contrib,
> >> mimepull.jar
> >> etc... well it works but not with Jmeter request)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>