Open gbersac opened 6 years ago
Any progress on this?
Tried to get running but after 2hr just don't have more time ...
Tried following https://github.com/lloydmeta/slim-play including using the conf file. However, I could not figure out how to add it to the class path or programmatically configure. Tried system env override of application.conf with this ....
java -Dconfig.file=/Users/me/application.conf -jar $(which amm) --no-remote-logging playtest.sc
...but still can't load the app. Here's the error:
@7802832ib: Cannot load play.application.loader play.utils.Reflect$.loadClass$1(Reflect.scala:111) play.utils.Reflect$.configuredClass(Reflect.scala:124) play.api.ApplicationLoader$.apply(ApplicationLoader.scala:73) ammonite.$file.playtest$.
(playtest.sc:65) ammonite.$file.playtest$. (playtest.sc) java.lang.ClassNotFoundException: AppLoader java.net.URLClassLoader.findClass(URLClassLoader.java:381) ammonite.runtime.SpecialClassLoader.findClass(ClassLoaders.scala:218) java.lang.ClassLoader.loadClass(ClassLoader.java:424) java.lang.ClassLoader.loadClass(ClassLoader.java:357) play.utils.Reflect$.loadClass$1(Reflect.scala:105) play.utils.Reflect$.configuredClass(Reflect.scala:124) play.api.ApplicationLoader$.apply(ApplicationLoader.scala:73) ammonite.$file.playtest$. (playtest.sc:65) ammonite.$file.playtest$. (playtest.sc)
Here's the code from playtest.sc
import scala.concurrent.Future
class AppComponents(context: Context) extends BuiltInComponentsFromContext(context) {
println("AppComponents...")
val httpFilters = Nil
//private val Action = defaultActionBuilder
val router: Router = Router.from {
// Essentially copied verbatim from the SIRD example
case GET(p"/hello/$to") =>
defaultActionBuilder {
Ok(s"Hello $to")
}
case GET(p"/sqrt/${double(num)}") =>
defaultActionBuilder.async {
Future {
Ok(Math.sqrt(num).toString)
}
}
}
}
class AppLoader extends ApplicationLoader {
def load(context: Context) = new AppComponents(context).application
println("AppLoader...")
}
val env = Environment(new java.io.File("."), this.getClass.getClassLoader, Mode.Dev)
val context = ApplicationLoader.createContext(env)
val loader = ApplicationLoader(context)
val app = loader.load(context)
Play.start(app)
StdIn.readLine()
Play.stop(app)
When I try to import play using the code snippet in the documentation, I get the following error :
Now, if I try to impot it using the new dependencies system for scripts :
Will give the following erro :
Could you please help me import play in ammonite scripts ? I also think that the documentation should be updated to have a valid (and up to date)
Play Framework Server
section