0

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?

KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Rajashree Gr
  • 519
  • 1
  • 9
  • 18

2 Answers2

0

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"

Sam Upra
  • 737
  • 5
  • 12
  • I created using the command - 'sbt new scalatra/scalatra-sbt.g8' which is given in Scalatra official website: http://scalatra.org/getting-started/first-project.html – Rajashree Gr Sep 02 '17 at 14:14
  • I added the resolver, but it is still showing the same warning. resolvers ++= Seq(Classpaths.typesafeReleases, "Jetty" at "https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-webapp") – Rajashree Gr Sep 02 '17 at 14:25
  • Suddenly the issue is resolved now when I did sbt build again. Trust me I tried it so many times but it didn't work before. But still, it shows me an error message "not a valid key: jetty" when I run the command jetty:start. – Rajashree Gr Sep 02 '17 at 14:41
  • Ok. Awesome! Congrats – Sam Upra Sep 03 '17 at 09:06
0

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)
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
  • Everything matches except the organization, name and mongodb dependency. I hope those changes does not matter in this case. I was getting the same warning for logback dependency also. I didn't mention it in the question as it started working when I used different dependency for it. – Rajashree Gr Sep 02 '17 at 14:29
  • Suddenly the issue is resolved now when I did sbt build again. Trust me I tried it so many times but it didn't work before. But still, it shows me an error message "not a valid key: jetty" when I run the command jetty:start. – Rajashree Gr Sep 02 '17 at 14:41