简体   繁体   中英

How do I run a Play Framework 2.4.4 application as a Windows service?

I was trying to follow the steps described in

How do I run a Play Framework 2.0 application as a Windows service?

And i failed at step 5. At first the service showed an error regarding the

play.core.server.NettyServer

part of the script. I changed it to

play.core.server.ProdServerStart

But now I get an error running the start.bat saying

C:\GCS>java -cp "C:\GCS\lib\*" play.core.server.ProdServerStart
Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties]
        at play.api.Configuration$.configError(Configuration.scala:178)
        at play.api.Configuration$.load(Configuration.scala:103)
        at play.api.Configuration$.load(Configuration.scala:133)
        at play.api.ApplicationLoader$.createContext(ApplicationLoader.scala:91)
        at play.core.server.ProdServerStart$.start(ProdServerStart.scala:50)
        at play.core.server.ProdServerStart$.main(ProdServerStart.scala:27)
        at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Caused by: com.typesafe.config.ConfigException$IO: application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties
        at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:236)
        at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:132)
        at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:1024)
        at com.typesafe.config.ConfigFactory.parseApplicationConfig(ConfigFactory.java:238)
        at com.typesafe.config.ConfigFactory.defaultApplication(ConfigFactory.java:519)
        at play.api.Configuration$$anonfun$3.apply(Configuration.scala:75)
        at play.api.Configuration$$anonfun$3.apply(Configuration.scala:71)
        at scala.Option.getOrElse(Option.scala:121)
        at play.api.Configuration$.load(Configuration.scala:71)
        ... 5 more
Caused by: com.typesafe.config.ConfigException$IO: application.conf: java.io.IOException: resource not found on classpath: application.conf
        at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:188)
        at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
        at com.typesafe.config.impl.Parseable.parse(Parseable.java:152)
        at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:185)
        ... 13 more
Caused by: java.io.IOException: resource not found on classpath: application.conf
        at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:735)
        at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:710)
        at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
        ... 16 more

I've looked for a solution for this everywhere, but couldn't find any.

I guess something else has changed in the way the dist is built since the original answer was given.

Anyone knows what could be the issue?

You need the config. on the classpath as well ie. depending on where your conf is, try something like the following (untested):

java -cp ".conf;.;lib/*" play.core.server.ProdServerStart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM