wiremock/wiremock-grpc-extension

WireMockHandlerDispatchingServlet is not a javax.servlet.Servlet

imochurad opened this issue · 1 comments

Proposal

I realize that this it must be some lib mismatch, cannot put a finger on what it is...

Failures (1):
  JUnit Jupiter:GrpcServiceComponentTest
    ClassSource [className = 'package.MetadataGrpcServiceComponentTest', filePosition = null]
    => com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: MultiException[javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.NotMatchedServlet is not a javax.servlet.Servlet, javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet is not a javax.servlet.Servlet]
       com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:166)
       com.github.tomakehurst.wiremock.junit5.WireMockExtension.startServerIfRequired(WireMockExtension.java:163)
       com.github.tomakehurst.wiremock.junit5.WireMockExtension.beforeAll(WireMockExtension.java:228)
       org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$12(ClassBasedTestDescriptor.java:395)
       org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
       [...]
       Suppressed: java.lang.NullPointerException
         com.github.tomakehurst.wiremock.junit5.WireMockExtension.stopServerIfRunning(WireMockExtension.java:216)
         com.github.tomakehurst.wiremock.junit5.WireMockExtension.afterAll(WireMockExtension.java:254)
         org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$18(ClassBasedTestDescriptor.java:461)
         org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
         org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$19(ClassBasedTestDescriptor.java:461)
         [...]
     Caused by: java.lang.RuntimeException: MultiException[javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.NotMatchedServlet is not a javax.servlet.Servlet, javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet is not a javax.servlet.Servlet]
       com.github.tomakehurst.wiremock.jetty.JettyHttpServer.start(JettyHttpServer.java:198)
       com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:164)
       [...]
     Caused by: MultiException[javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.NotMatchedServlet is not a javax.servlet.Servlet, javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet is not a javax.servlet.Servlet]
       org.eclipse.jetty.util.MultiException.ifExceptionThrow(MultiException.java:117)
       org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:751)
       org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392)
       org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:901)
       org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306)
       [...]
       Suppressed: javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet is not a javax.servlet.Servlet
         org.eclipse.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:514)
         org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:386)
         org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
         org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$2(ServletHandler.java:724)
         java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
         [...]
     Caused by: javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.NotMatchedServlet is not a javax.servlet.Servlet
       org.eclipse.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:514)
       org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:386)
       org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
       org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$2(ServletHandler.java:724)
       java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
       [...]

Reproduction steps

package com.salesforce.fieldservice.metadatafeed

import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import com.github.tomakehurst.wiremock.junit5.WireMockExtension
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.RegisterExtension
import org.wiremock.grpc.GrpcExtensionFactory
import org.wiremock.grpc.dsl.WireMockGrpcService

@ExtendWith(WireMockExtension::class)
class GrpcServiceComponentTest {

companion object {
    @JvmField
    @RegisterExtension
    val wm: WireMockExtension = WireMockExtension.newInstance()
        .options(
            wireMockConfig()
                .dynamicPort()
                .withRootDirectory("src/test/resources/wiremock")
                .extensions(GrpcExtensionFactory())
        )
        .build()
}

private var mockJwtGenerationService: WireMockGrpcService? = null


@BeforeEach
fun init() {
    mockJwtGenerationService = WireMockGrpcService(WireMock(wm.port), "salesforce.cdp.authenticationservice.jwt.v1.JwtGenerationService")
}

@Test
fun dummyTest() {
    assertThat(5).isNotNull()
}

}

References

No response

This is likely due to the Jetty version you already have on your classpath. Suggest you post this to the Slack community if you still need any help.