Jetty-webapp unknown artifact in sbt

238 views Asked by At

I created Scalatara application to build a web service. It uses Jetty server and it was included in the build.sbt file when I created the project itself.

But when I try to start the jetty server using the command - jetty:start, it shows me an error message "not a valid key: jetty". Then when I checked the build file, it shows a warning message as "unknown artifact in sbt" for the below dependency.

"org.eclipse.jetty" % "jetty-webapp" % "9.4.6.v20170531" % "container"

I used the latest dependency from the MVN Repository but still, it shows the same error. Is there anything else I have to do here?

2

There are 2 answers

4
Sam Upra On

How did you create the project? Is there a way you can tell me so I can reproduce it. Will be much easier to figure out. Anyways, you can try to add a resolver first to your build.sbt :

resolvers += "Jetty" at "https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-webapp"

2
KARTHIKEYAN.A On

Kindly compare the code of build.sbt file shown below and if anything missing you should update in you build.st file.

import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import ScalateKeys._

val ScalatraVersion = "2.5.1"

ScalatraPlugin.scalatraSettings

scalateSettings

organization := "com.github.karthikeyana"

name := "My Scalatra Web App"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.12.3"

resolvers += Classpaths.typesafeReleases

libraryDependencies ++= Seq(
  "org.scalatra" %% "scalatra" % ScalatraVersion,
  "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
  "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
  "ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
  "org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
  "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  "org.mongodb" %% "casbah" % "3.1.1"
)

scalateTemplateConfig in Compile := {
  val base = (sourceDirectory in Compile).value
  Seq(
    TemplateConfig(
      base / "webapp" / "WEB-INF" / "templates",
      Seq.empty,  /* default imports should be added here */
      Seq(
        Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
      ),  /* add extra bindings here */
      Some("templates")
    )
  )
}

enablePlugins(JettyPlugin)