users@jersey.java.net

[Jersey] Multipart 1.0.3 not finding message body reader

From: Ari.Heino <ext.ari.heino_at_tieto.com>
Date: Tue, 21 Apr 2009 00:18:11 -0700 (PDT)

Hi!

I've been trying to use jersey multipart library 1.0.3 (both snapshot and
the recently released version) and it always gives me this error when I try
to POSt a multipart message:

14 * In-bound request received
14 > POST http://localhost:8080/projects/ProjectA/contents/.project
14 > Content-Length: 622
14 > Host: localhost:8080
14 > User-Agent: Jakarta Commons-HttpClient/3.1
14 > X-USER: Mike
14 > Content-Type:
multipart/mixed;boundary=Boundary_1_23427075_1240297497484
14 > Accept: multipart/mixed
14 > MIME-Version: 1.0
14 >

--Boundary_1_23427075_1240297497484
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><versionContentDto><versionDate>2009-04-21T10:04:57.406+03:00</versionDate><name>.project</name><author>Mike</author><resourceId>603</resourceId></versionContentDto>
--Boundary_1_23427075_1240297497484
Content-Type: application/octet-stream

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>Ari6</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
        </buildSpec>
        <natures>
        </natures>
</projectDescription>

--Boundary_1_23427075_1240297497484--


21.4.2009 10:04:57 com.sun.jersey.spi.container.ContainerRequest getEntity
SEVERE: A message body reader for Java type, class
com.sun.jersey.multipart.MultiPart, and MIME media type,
multipart/mixed;boundary=Boundary_1_23427075_1240297497484, was not found
javax.ws.rs.WebApplicationException


Webg application exception (415) handled by WebApplicationExceptionHandler:
null
        at
com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:388)
        at
com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:139)
        at
com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:43)
        at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:126)
        at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:173)
        at
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
        at
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:163)
        at
com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:105)
        at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
        at
com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:105)
        at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
        at
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
        at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
        at
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:654)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:612)
        at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:603)
        at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
        at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)
        at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:590)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at
org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
        at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
        at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at
org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:269)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
        at
org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
        at org.mortbay.http.HttpServer.service(HttpServer.java:909)
        at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
        at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
        at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

Here's the resource method:

    @POST
    @Consumes(MultiPartMediaTypes.MULTIPART_MIXED)
    public Response add(MultiPart multiPart) {
        VersionContentDto dto;
        try {
            dto =
multiPart.getBodyParts().get(0).getEntityAs(VersionContentDto.class);
        } catch (Exception e1) {
            dto = (VersionContentDto)
multiPart.getBodyParts().get(0).getEntity();
        }
    }

Any ideas what is wrong?

The way I've currently fixed this is to use multipart 1.0.2 library.


-- 
View this message in context: http://n2.nabble.com/Multipart-1.0.3-not-finding-message-body-reader-tp2668407p2668407.html
Sent from the Jersey mailing list archive at Nabble.com.