java.lang.IllegalStateException: No multipart config for servlet

1,379 views
Skip to first unread message

Christian Bonzelet

unread,
Sep 21, 2018, 2:34:41 AM9/21/18
to wiremock-user
Hi Wiremock-Users,

according to https://groups.google.com/forum/#!topic/wiremock-user/dYjskyLaLSE is there another way to make multipart-file uploads work instead of downgrading the jetty dependencies?

Getting this error message when trying to test a multipar-fileupload
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 Server Error</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /my-file-upload-resource. Reason:
<pre> Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.IllegalStateException: No multipart config for servletat org.eclipse.jetty.server.Request.getParts(Request.java:2331)at org.eclipse.jetty.server.Request.getParts(Request.java:2319)at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.safelyGetRequestParts(WireMockHttpServletRequestAdapter.java:295)at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.getParts(WireMockHttpServletRequestAdapter.java:279)at com.github.tomakehurst.wiremock.matching.MultipartValuePattern.matchAnyMultipart(MultipartValuePattern.java:105)at com.github.tomakehurst.wiremock.matching.MultipartValuePattern.match(MultipartValuePattern.java:90)at com.github.tomakehurst.wiremock.matching.RequestPattern$6.apply(RequestPattern.java:278)at com.github.tomakehurst.wiremock.matching.RequestPattern$6.apply(RequestPattern.java:276)at com.google.common.collect.Iterators$7.transform(Iterators.java:750)at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:252)at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:209)at com.google.common.collect.FluentIterable.toList(FluentIterable.java:614)at com.github.tomakehurst.wiremock.matching.RequestPattern.allMultipartPatternsMatch(RequestPattern.java:274)at com.github.tomakehurst.wiremock.matching.RequestPattern.access$600(RequestPattern.java:44)at com.github.tomakehurst.wiremock.matching.RequestPattern$1.match(RequestPattern.java:61)at com.github.tomakehurst.wiremock.matching.RequestPattern$1.match(RequestPattern.java:58)at com.github.tomakehurst.wiremock.matching.RequestPattern.match(RequestPattern.java:165)at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings$3.apply(InMemoryStubMappings.java:183)at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings$3.apply(InMemoryStubMappings.java:181)at com.google.common.collect.Iterators$6.computeNext(Iterators.java:617)at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)at com.google.common.collect.Iterators.getNext(Iterators.java:818)at com.google.common.collect.Iterators.find(Iterators.java:688)at com.google.common.collect.Iterables.find(Iterables.java:638)at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:65)at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:164)at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50)at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:44)at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108)at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:674)at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)at org.eclipse.jetty.server.Server.handle(Server.java:531)at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:132)at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)at java.lang.Thread.run(Thread.java:748)
</pre>
<hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.11.v20180605</a><hr/></body>
</html>


And here my test:

stubFor(post(urlPathMatching("/my-file-upload-resource"))
 
.withMultipartRequestBody(
    aMultipart
()
     
.withName("files")
     
.withHeader("Content-Type", containing("image/jpeg")))
 
.willReturn(aResponse()
 
.withStatus(200)));

Thanks in advance,

Christian

Christian Bonzelet

unread,
Sep 21, 2018, 2:38:20 AM9/21/18
to wiremock-user
Downgrading to jetty 9.4.9 also works...but it remains ugly :D

<!--
explicit downgrade wiremocks jetty server to make multipart file uploads work with servlet spec 3.0.
see https://groups.google.com/forum/#!topic/wiremock-user/dYjskyLaLSE and https://bugs.eclipse.org/bugs/show_bug.cgi?id=395000
for further details
-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.9.v20180320</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.9.v20180320</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>9.4.9.v20180320</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.9.v20180320</version>
<scope>test</scope>
</dependency>
Reply all
Reply to author
Forward
0 new messages