0

我正在使用 socko 的 restful api。当我通过 运行我的应用程序时sbt run,可以毫无问题地运行。但是,当我通过 打包我的应用程序one-jar并运行它java -jar myapp_2.10-1.0-onejar.jar时,会发生运行时错误。所以我想知道jar文件和我的应用程序有什么问题。谢谢你。

以下是我的sbt about结果:

[info] Loading project definition from /path/to/myapp/project
[info] Set current project to root (in build file:/path/to/myapp/)
[info] This is sbt 0.13.1
[info] The current project is {file:/path/to/myapp/}root 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.3
[info] Available Plugins: com.github.retronym.SbtOneJar
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.3

以下是运行时错误消息:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.simontuffs.onejar.Boot.run(Boot.java:340)
    at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.ExceptionInInitializerError
    at com.netease.cloudstudyindex.httpapi.IndexService.main(IndexService.scala)
    ... 6 more
Caused by: java.lang.RuntimeException: No resource for com/pkgpath/httpapi
    at org.mashupbots.socko.infrastructure.ReflectUtil$.getClasses(ReflectUtil.scala:43)
    at org.mashupbots.socko.rest.RestRegistry$$anonfun$3.apply(RestRegistry.scala:127)
    at org.mashupbots.socko.rest.RestRegistry$$anonfun$3.apply(RestRegistry.scala:127)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
    at org.mashupbots.socko.rest.RestRegistry$.apply(RestRegistry.scala:127)
    at org.mashupbots.socko.rest.RestRegistry$.apply(RestRegistry.scala:102)
    at com.netease.cloudstudyindex.httpapi.IndexService$.<init>(IndexService.scala:40)
    at com.netease.cloudstudyindex.httpapi.IndexService$.<clinit>(IndexService.scala)
    ... 7 more

以下是 的部分结果jar -tf myapp_2.10-1.0.jar,其中myapp_2.10-1.0.jarmyapp_2.10-1.0-onejar.jar生成one-jar

com/pkgpath/httpapi/StatIndexProcessor$$anonfun$paginate$1.class
com/pkgpath/httpapi/LessonSourceIndexRegistration$.class
com/pkgpath/httpapi/RankIndexProcessor$$anonfun$1.class
com/pkgpath/httpapi/StatContent$$anonfun$merge$1.class
com/pkgpath/httpapi/RankIndexProcessor$$anonfun$getRankContents$1.class
com/pkgpath/httpapi/CourseRankIndexResponse$.class
4

1 回答 1

0

socko web server 有一个bug,我已经解决了github上下面issue的bug。

GitHub:在 RestRegistry 中我的/包没有资源

于 2015-02-10T04:06:41.167 回答