hi <@U0592TMJU4V> /<@U053QJ8NGNS> getting 500 Ser...
# wiremock-java
d
hi @Lee Turner /@Bas Dijkstra getting 500 Server Error when request body has bankCode as null or accountNumber as null. Would need your help to resolve this. Last option could be updating to latest version, but I need to know if any other way attaching the failure response in sub convo screen
using wiremock version- wiremock-webhooks-extension-2.32.0.jar:wiremock-standalone-2.32.0.ja
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Error 500 java.lang.NullPointerException</title>
</head>
<body>
<h2>HTTP ERROR 500 java.lang.NullPointerException</h2>
<table>
<tr>
<th>URI:</th>
<td>/wiremock/hom/in/in2/in3/in4</td>
</tr>
<tr>
<th>STATUS:</th>
<td>500</td>
</tr>
<tr>
<th>MESSAGE:</th>
<td>java.lang.NullPointerException</td>
</tr>
<tr>
<th>SERVLET:</th>
<td>com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet-1f651cd8</td>
</tr>
<tr>
<th>CAUSED BY:</th>
<td>java.lang.NullPointerException</td>
</tr>
</table>
<h3>Caused by:</h3>
<pre>java.lang.NullPointerException
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at com.github.tomakehurst.wiremock.matching.MatchesJsonPathPattern.getExpressionResult(MatchesJsonPathPattern.java:145)
at com.github.tomakehurst.wiremock.matching.MatchesJsonPathPattern.isAdvancedMatch(MatchesJsonPathPattern.java:90)
at com.github.tomakehurst.wiremock.matching.PathPattern.match(PathPattern.java:46)
at com.github.tomakehurst.wiremock.matching.PathPattern.match(PathPattern.java:22)
at com.github.tomakehurst.wiremock.matching.RequestPattern$5.apply(RequestPattern.java:348)
at com.github.tomakehurst.wiremock.matching.RequestPattern$5.apply(RequestPattern.java:340)
at <http://wiremock.com|wiremock.com>.google.common.collect.Iterators$6.transform(Iterators.java:826)
at <http://wiremock.com|wiremock.com>.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)
at <http://wiremock.com|wiremock.com>.google.common.collect.ImmutableList.copyOf(ImmutableList.java:278)
at <http://wiremock.com|wiremock.com>.google.common.collect.ImmutableList.copyOf(ImmutableList.java:239)
at <http://wiremock.com|wiremock.com>.google.common.collect.FluentIterable.toList(FluentIterable.java:631)
at com.github.tomakehurst.wiremock.matching.RequestPattern.allBodyPatternsMatch(RequestPattern.java:354)
at com.github.tomakehurst.wiremock.matching.RequestPattern.access$800(RequestPattern.java:43)
at com.github.tomakehurst.wiremock.matching.RequestPattern$1.match(RequestPattern.java:104)
at com.github.tomakehurst.wiremock.matching.RequestPattern$1.match(RequestPattern.java:90)
at com.github.tomakehurst.wiremock.matching.RequestPattern.match(RequestPattern.java:226)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings$3.apply(InMemoryStubMappings.java:231)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings$3.apply(InMemoryStubMappings.java:229)
at <http://wiremock.com|wiremock.com>.google.common.collect.Iterators.find(Iterators.java:755)
at <http://wiremock.com|wiremock.com>.google.common.collect.Iterables.find(Iterables.java:689)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:76)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:225)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:57)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:69)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:142)
at wiremock.javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1631)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.Server.handle(Server.java:516)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:400)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:645)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:392)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.FillInterest.fillable(FillInterest.java:105)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:137)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.base/java.lang.Thread.run(Thread.java:833)
</pre>
</body>
</html>
l
Can you post your json mapping file?
d
Copy code
{
  "request": {
    "url": "/wiremock/hom/in/in2/in3/in4",
    "method": "POST",
    "bodyPatterns": [
      {
        "matchesJsonPath": {
          "expression": "$.name",
          "contains": "abcde"
        }
      }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "folder/ResponseSuccess.json",
    "headers": {
      "Content-Type": "application/json; charset=utf-8"
    }
  }
}
ResponseSuccess.json:
Copy code
{
  "code": "200",
  "ICode": "172222112222445728394",
  "oNo": "4842229",
  "sCode": "RAQC"
}
l
So
name
is an optional part of the request?
What would a request look like in this case?
d
yes. name is optional
{ "date": "06/28/2024 052351", "orderNumber": null, "cpf": "12345", "name": "abcde", "bankCode": null }
@Lee Turner
b
So, I set up a little project with that specific WireMock standalone version, with your request mapping, with your response file, with your folder structure, and on my machine WireMock responds as expected:
d
it's working at my end too, when I avoid bankCode lik ebelow- { "date": "06/28/2024 052351", "orderNumber": null, "cpf": "12345", "name": "abcde" } but moment I provide it as null it's the same 500Server Error
not sure why
<th>STATUS:</th> <td>500</td> </tr> <tr> <th>MESSAGE:</th> <td>java.lang.NullPointerException</td> </tr> <tr> <th>SERVLET:</th> <td>com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet-47c64cfe</td> </tr> <tr> <th>CAUSED BY:</th> <td>java.lang.NullPointerException</td> </tr> </table> <h3>Caused by:</h3> <pre>java.lang.NullPointerException at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
b
A couple of things to check: • Do you have other responses defined that could match this request? I.e., for the same endpoint and HTTP verb? • Can you start the WireMock server with the
--verbose
flag and post the output here?
l
I agree with @Bas Dijkstra. I have just tried this myself (all be it with the latest version) and it works as expected.
d
sure, will do and paste here once done
it's getting teared up before matching the request format itself, no verbose is generated in this case
l
Sorry, what do you mean when you say it is getting teared up before matching ?
b
^^ This. It's impossible to guess what's happening on your system. Please be as specific as you can.
d
I enabled verbose. When a particular match is found for a request, on Wiremock server we see matched stub and related things. I can't see any such entry at all when I pass bankCode as null. I get the response what I sent you in above chats.
b
That’s probably an indication that the request get mangled before arriving at WireMock. Is there a way to scan the network traffic using a tool like https://www.telerik.com/fiddler and see what’s going on?
d
will try for sure