Groovy + Dropwizard and servlet 3.1.0 issue -


i trying create simple rest server using groovy 2.4.1, based on dropwizard framework 0.8.1. groovy script i'm using proof of concept is:

import com.codahale.metrics.annotation.timed import com.google.common.base.optional import io.dropwizard.application import io.dropwizard.configuration import io.dropwizard.setup.bootstrap import io.dropwizard.setup.environment  import javax.ws.rs.get import javax.ws.rs.path import javax.ws.rs.produces import javax.ws.rs.queryparam import javax.ws.rs.core.mediatype  @grapes([         @grab(group = 'io.dropwizard', module = 'dropwizard-core', version = '0.8.1')])  class restproviderconfiguration extends configuration {     string template }  class restproviderapplication extends application<restproviderconfiguration> {      @override     string getname() {         'hello-world'     }      @override     void initialize(bootstrap<restproviderconfiguration> bootstrap) {     }      @override     void run(restproviderconfiguration configuration, environment environment) {         def resource = new helloworldresource(template: configuration.template);         environment.jersey().register(resource);     } }   @path('/hello-world') @produces(mediatype.application_json) class helloworldresource {      string template      @get     @timed     string sayhello(@queryparam('name') optional<string> name) {         string.format(template, name.or('john doe'))     } }  new restproviderapplication().run(args) 

the server starts on request on resource /hello-world, following exception thrown:

warn  [2015-05-11 12:17:04,099] org.eclipse.jetty.servlet.servlethandler: error /hello-world ! java.lang.nosuchmethoderror: javax.servlet.http.httpservletresponse.getheader(ljava/lang/string;)ljava/lang/string; ! @ org.eclipse.jetty.servlets.gzipfilter.dofilter(gzipfilter.java:322) ~[jetty-servlets-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ io.dropwizard.jetty.bidigzipfilter.dofilter(bidigzipfilter.java:134) ~[dropwizard-jetty-0.8.1.jar:0.8.1] ! @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1652) ~[jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ io.dropwizard.servlets.threadnamefilter.dofilter(threadnamefilter.java:29) ~[dropwizard-servlets-0.8.1.jar:0.8.1] ! @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1652) ~[jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ io.dropwizard.jersey.filter.allowedmethodsfilter.handle(allowedmethodsfilter.java:44) ~[dropwizard-jersey-0.8.1.jar:0.8.1] ! @ io.dropwizard.jersey.filter.allowedmethodsfilter.dofilter(allowedmethodsfilter.java:39) ~[dropwizard-jersey-0.8.1.jar:0.8.1] ! @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1652) ~[jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:585) [jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1127) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:515) [jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:1061) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:141) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ com.codahale.metrics.jetty9.instrumentedhandler.handle(instrumentedhandler.java:240) [metrics-jetty9-3.1.1.jar:3.1.1] ! @ io.dropwizard.jetty.routinghandler.handle(routinghandler.java:51) [dropwizard-jetty-0.8.1.jar:0.8.1] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.requestloghandler.handle(requestloghandler.java:95) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.statisticshandler.handle(statisticshandler.java:159) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.server.handle(server.java:497) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpchannel.handle(httpchannel.java:310) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpconnection.onfillable(httpconnection.java:257) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.io.abstractconnection$2.run(abstractconnection.java:540) [jetty-io-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:635) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:555) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ java.lang.thread.run(thread.java:744) [na:1.7.0_45] 127.0.0.1 - - [11/may/2015:12:17:04 +0000] "get /hello-world http/1.1" 500 - "-" "mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.135 sa fari/537.36" 22 warn  [2015-05-11 12:17:04,104] org.eclipse.jetty.server.httpchannel: /hello-world ! java.lang.nosuchmethoderror: javax.servlet.http.httpservletresponse.getstatus()i ! @ com.codahale.metrics.jetty9.instrumentedhandler.updateresponses(instrumentedhandler.java:291) ~[metrics-jetty9-3.1.1.jar:3.1.1] ! @ com.codahale.metrics.jetty9.instrumentedhandler.handle(instrumentedhandler.java:254) ~[metrics-jetty9-3.1.1.jar:3.1.1] ! @ io.dropwizard.jetty.routinghandler.handle(routinghandler.java:51) ~[dropwizard-jetty-0.8.1.jar:0.8.1] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.requestloghandler.handle(requestloghandler.java:95) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.statisticshandler.handle(statisticshandler.java:159) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.server.handle(server.java:497) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpchannel.handle(httpchannel.java:310) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpconnection.onfillable(httpconnection.java:257) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.io.abstractconnection$2.run(abstractconnection.java:540) [jetty-io-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:635) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:555) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ java.lang.thread.run(thread.java:744) [na:1.7.0_45] warn  [2015-05-11 12:17:04,105] org.eclipse.jetty.util.thread.queuedthreadpool: ! java.lang.nosuchmethoderror: javax.servlet.http.httpservletresponse.getstatus()i ! @ org.eclipse.jetty.server.handler.errorhandler.handle(errorhandler.java:111) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.response.senderror(response.java:597) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpchannel.handleexception(httpchannel.java:486) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpconnection$httpchanneloverhttp.handleexception(httpconnection.java:576) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpchannel.handle(httpchannel.java:386) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.server.httpconnection.onfillable(httpconnection.java:257) ~[jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.io.abstractconnection$2.run(abstractconnection.java:540) ~[jetty-io-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:635) ~[jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:555) ~[jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224] ! @ java.lang.thread.run(thread.java:744) [na:1.7.0_45] warn  [2015-05-11 12:17:04,105] org.eclipse.jetty.util.thread.queuedthreadpool: unexpected thread death: org.eclipse.jetty.util.thread.queuedthreadpool$3@5bdb85f9 in dw{started,8<= 8<=1024,i=1,q=0} 

this because groovy classpath has groovy-servlet-2.4.3.jar 2.4 servlet version , dropwizard 0.8.1 has javax.servlet-api-3.1.0.jar.

can tell me how replace groovy jar or load required version first?

i have ran similar issue. in case problem there other dependency had javax.servlet-api-2.5.0.jar had 2 versions of javax.servlet-api

mvn dependency:tree -dincludes=*:*servlet*  mystuff:mystuff:jar:1.0-snapshot   mystuff:rest-support:jar:2.0.0-release:compile   |  \- com.github.kongchen:swagger-maven-plugin:jar:2.3.4:compile   |     \- javax.servlet:servlet-api:jar:2.5:compile   ...   \- mystuff:myotherstuff:jar:2.2.4:compile      \- javax.servlet:javax.servlet-api:jar:3.1.0:compile 

i fixed manually excluding swagger-maven-plugin maven dependencies of mystuff:rest-support

hope helps


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -