打包使用Native sbt Packager播放Windows应用程序

时间:2015-06-30 09:16:01

标签: scala playframework sbt typesafe-activator sbt-native-packager

我玩了一个小的HTTP服务器。我现在想用安装来构建一个windows版本。几个月前我已经做了一个,但我修改了我的应用程序,所以我必须重新安装。但是,如果不改变sbt文件中的所有内容,它就会失败......

这里是我用来构建安装的命令:

activator windows:packageBin

这是我在安装后启动应用程序时遇到的错误:

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$.play$api$Configuration$$configError(Configuration.scala:94)
        at play.api.Configuration$.load(Configuration.scala:66)
        at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration$1.apply(Application.scala:76)
        at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration$1.apply(Application.scala:76)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.api.WithDefaultConfiguration$class.initialConfiguration(Application.scala:75)
        at play.api.DefaultApplication.initialConfiguration$lzycompute(Application.scala:402)
        at play.api.DefaultApplication.initialConfiguration(Application.scala:402)
        at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalClass(Application.scala:25)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass$lzycompute(Application.scala:402)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass(Application.scala:402)
        at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:31)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal$lzycompute(Application.scala:402)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:402)
        at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:54)
        at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:53)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:52)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:402)
        at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:402)
        at play.api.WithDefaultGlobal$class.global(Application.scala:68)
        at play.api.DefaultApplication.global(Application.scala:402)
        at play.api.WithDefaultConfiguration$class.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:82)
        at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration$lzycompute(Application.scala:402)
        at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:402)
        at play.api.WithDefaultConfiguration$class.configuration(Application.scala:84)
        at play.api.DefaultApplication.configuration(Application.scala:402)
        at play.api.Application$class.$init$(Application.scala:274)
        at play.api.DefaultApplication.<init>(Application.scala:406)
        at play.core.StaticApplication.<init>(ApplicationProvider.scala:53)
        at play.core.server.NettyServer$.createServer(NettyServer.scala:253)
        at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:289)
        at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:284)
        at scala.Option.map(Option.scala:145)
        at play.core.server.NettyServer$.main(NettyServer.scala:284)
        at play.core.server.NettyServer.main(NettyServer.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:235)
        at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:128)
        at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:811)
        at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:113)
        at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:136)
        at com.typesafe.config.ConfigFactory.loadDefaultConfig(ConfigFactory.java:228)
        at com.typesafe.config.ConfigFactory.access$000(ConfigFactory.java:38)
        at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:378)
        at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:375)
        at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:58)
        at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:86)
        at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:375)
        at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:299)
        at play.api.Configuration$.dontAllowMissingConfig$lzycompute(Configuration.scala:29)
        at play.api.Configuration$.dontAllowMissingConfig(Configuration.scala:29)
        at play.api.Configuration$.load(Configuration.scala:64)
        ... 34 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:183)
        at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:170)
        at com.typesafe.config.impl.Parseable.parse(Parseable.java:148)
        at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:185)
        ... 49 more
Caused by: java.io.IOException: resource not found on classpath: application.conf
        at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:579)
        at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:554)
        at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:176)
        ... 52 more

这是我的sbt文件:

name := """IDTabDriver"""

name in Windows := "IdTabDriver"

packageSummary in Windows := "IdTabDriver"

packageDescription in Windows := "IdTabDriver"

maintainer in Windows := "My Company"

organization := "My Company"

version := "1.0.0.1"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  cache,
  javaWs,
  "commons-configuration" % "commons-configuration" % "1.10",
  "org.rxtx" % "rxtxcomm" % "2.0-7pre1"
)

如果有人有想法,我已经尝试了很多我无法找到解决方案的东西

2 个答案:

答案 0 :(得分:1)

我也遇到了同样的错误,抱怨在classpath上找不到资源application.conf。这可能与sbt-play插件中的know bug有关。在recent bug fix发布之前,请尝试将以下行添加到build.sbt,作为suggested by the Play development team的解决方法。

$(function(){
  'use strict';
  var $page = $('#main'),
      options = {
        debug: true,
        prefetch: true,
        cacheLength: 2,
        forms: 'form',
        onStart: {
          duration: 250, // Duration of our animation
          render: function ($container) {
            // Add your CSS animation reversing class
            $container.addClass('is-exiting');
            // Restart your animation
            smoothState.restartCSSAnimations();
          }
        },
        onReady: {
          duration: 0,
          render: function ($container, $newContent) {
            // Remove your CSS animation reversing class
            $container.removeClass('is-exiting');
            // Inject the new content
            $container.html($newContent);
          }
        }
      },
      smoothState = $page.smoothState(options).data('smoothState');

});

这对我有用。

答案 1 :(得分:-1)

如果您只是使用Play附带的内容,那么您需要在SBT控制台中运行dist

然后在target/universal中查找压缩文件。解压缩时运行.bat文件夹中的bin文件。