Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WireMock server failing to stop with Cucumber #37

Closed
ihaworth opened this issue May 31, 2013 · 3 comments
Closed

WireMock server failing to stop with Cucumber #37

ihaworth opened this issue May 31, 2013 · 3 comments

Comments

@ihaworth
Copy link

I've been using WireMock with Cucumber (Cuke4Duke and CucumberJVM) and have been experiencing problems with the lifecycle of WireMock.

I start the server with the following as I can't use the @rule as it is for JUnit, not cucumber.

wireMockServer = new WireMockServer(wireMockConfig().port(8082));
wireMockServer.start();
WireMock.configureFor("localhost", 8082);
WireMock.reset();

and stopping with

wireMockServer.stop();

When wireMockServer.stop() is called then I get an exception

[INFO] 2013-05-31 15:26:24,748 [main] ERROR wiremock.org.mortbay.log - EXCEPTION 
[INFO] java.lang.NullPointerException
[INFO]        at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
[INFO]        at javax.servlet.GenericServlet.log(GenericServlet.java:300)
[INFO]        at javax.servlet.GenericServlet.destroy(GenericServlet.java:122)
[INFO]        at wiremock.org.mortbay.jetty.servlet.ServletHolder.destroyInstance(ServletHolder.java:318)
[INFO]        at wiremock.org.mortbay.jetty.servlet.ServletHolder.doStop(ServletHolder.java:289)
[INFO]        at wiremock.org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
[INFO]        at wiremock.org.mortbay.jetty.servlet.ServletHandler.doStop(ServletHandler.java:185)
[INFO]        at wiremock.org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
[INFO]        at wiremock.org.mortbay.jetty.handler.HandlerWrapper.doStop(HandlerWrapper.java:142)
[INFO]        at wiremock.org.mortbay.jetty.handler.ContextHandler.doStop(ContextHandler.java:592)
[INFO]        at wiremock.org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
[INFO]        at wiremock.org.mortbay.jetty.handler.HandlerCollection.doStop(HandlerCollection.java:169)
[INFO]        at wiremock.org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
[INFO]        at wiremock.org.mortbay.jetty.handler.HandlerWrapper.doStop(HandlerWrapper.java:142)
[INFO]        at wiremock.org.mortbay.jetty.Server.doStop(Server.java:283)
[INFO]        at wiremock.org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
[INFO]        at com.github.tomakehurst.wiremock.WireMockServer.stop(WireMockServer.java:148)
[INFO]        at com.thehutgroup.acceptancetests.support.MockOrderManager.stop(MockOrderManager.java:39)
[INFO]        at com.thehutgroup.acceptancetests.steps.SetupSteps.tearDown(SetupSteps.java:27)
[INFO]        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[INFO]        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[INFO]        at java.lang.reflect.Method.invoke(Method.java:597)
[INFO]        at cuke4duke.internal.java.MethodInvoker.invoke(MethodInvoker.java:21)
[INFO]        at cuke4duke.internal.jvmclass.ClassLanguage.invoke(ClassLanguage.java:120)
[INFO]        at cuke4duke.internal.jvmclass.ClassLanguage.invokeHook(ClassLanguage.java:114)
[INFO]        at cuke4duke.internal.java.JavaHook.invoke(JavaHook.java:22)
[INFO]        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[INFO]        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[INFO]        at java.lang.reflect.Method.invoke(Method.java:597)

Jetty seems not to close and the port (8082) is left occupied, such that should I start to run another test, starting WireMock fails to bind to port 8082.

@tomakehurst
Copy link
Member

Do you have an additional copy of the servlet API on the classpath?

In the version of GenericServlet embedded within Jetty, line 205 is a comment, which suggests the version you're running is different.

@ihaworth
Copy link
Author

ihaworth commented Jun 3, 2013

Good spot! That seems to be it. All working smoothly now. :) Thanks

@tomakehurst
Copy link
Member

No worries, glad you got it sorted.

@mikemike754
Copy link

I encounted the same problem. But I have only one servlet jar version in my pom:
CMD$: mvn dependency:tree | grep servlet
Output: [INFO] | - javax.servlet:servlet-api:jar:2.3:compile

What's possible reasons? @tomakehurst

and my pom version of wiremock is:

com.github.tomakehurst
wiremock-standalone
2.6.0

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants