I can't run jettyRun task from jetty plugin when trying to mount Scalatra servlet


(Paweł Stawicki) #1

I have Scalatra servlet, which extends javax.servlet.http.HttpServlet, and I’m trying to mount it to javax.servlet.ServletContext in ScalatraBootstrap. The error I’m getting:

failed org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext@58786c40{/gradle-jetty-bug,/Users/amorfis/idea-workspace/gradle-jetty-bug/src/main/webapp}: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;

failed ContextHandlerCollection@2b47486f: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;

failed HandlerCollection@54e4859b: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;

Error starting handlers

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;

at org.scalatra.servlet.RichServletContext.mountServlet(RichServletContext.scala:98)

at org.scalatra.servlet.RichServletContext.mount(RichServletContext.scala:69)

at org.scalatra.servlet.RichServletContext.mount(RichServletContext.scala:76)

at ScalatraBootstrap.init(ScalatraBootstrap.scala:12)

Which jetty version is the plugin using? Is it possible to set jetty version by hand? Or pass as a dependency?

This is how my configuration looks like:

configurations {

provided

compile.extendsFrom provided

}

dependencies {

provided “org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016”

compile “org.scalatra:scalatra_2.10:2.2.2”

}


(Benjamin Muschko) #2

The core Jetty plugin depends on an old version of Jetty (6.1.25). Unfortunately, you cannot change it. I’d recommend going with the advanced version of a Jetty plugin called Gretty. It provides far more options to configure it.