NullPointerException in ResponseDefinition.copyOf

64 views
Skip to first unread message

Sergei German

unread,
May 11, 2016, 12:27:07 PM5/11/16
to wiremock-user
Hi,
I'm using stand alone wiremock instance to test POST functionality  of a testing framework:

java -jar wiremock-1.57-standalone.jar --port 9090

in my mappings directory I have file: 

>cat mappings/postTest.json
{
    "request": {
        "method": "POST",
        "url": "/postTest"
        }
    },
    "response": {
            "status": 200,
            "body": "Hello world!",
            "headers": {
                    "Content-Type": "text/plain"
            }
     }
}

when issue 
 curl -H "Content-Type: application/json" -X POST -d '{"method": "POST","url":"/postTest"}'  http://localhost:9090/postTest

I receive an error 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 INTERNAL_SERVER_ERROR</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /postTest. Reason:
<pre>    INTERNAL_SERVER_ERROR</pre></p><h3>Caused by:</h3><pre>java.lang.NullPointerException
at com.github.tomakehurst.wiremock.http.ResponseDefinition.copyOf(ResponseDefinition.java:56)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:46)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:92)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:35)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:38)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.service(Jetty6HandlerDispatchingServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at com.github.tomakehurst.wiremock.jetty6.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
</pre>
<hr /><i><small>Powered by Jetty://</small></i><br/>


What do I need to do to make this work?

Thank you,
Sergei 

Tom Akehurst

unread,
May 23, 2016, 4:55:26 PM5/23/16
to wiremock-user
You have an extra closing brace you your mapping JSON. This has revealed some pretty terrible validation inside WireMock though, so I'll improve that to make it clearer what's happening.

This is what you need:

Sergei German

unread,
May 23, 2016, 5:12:17 PM5/23/16
to wiremock-user
Thanks!!
Reply all
Reply to author
Forward
0 new messages