Frage

I am using restful api of socko. When I run my application via sbt run, it is ok to run without any problem. However, when I package my application by one-jar and run it via java -jar myapp_2.10-1.0-onejar.jar, a runtime error occur. So I wonder what the problem with the jar file and my application is. Thank you.

Following is my sbt about result:

[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

Following is the runtime error message:

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

Following is the part of the result of jar -tf myapp_2.10-1.0.jar, where myapp_2.10-1.0.jar is in myapp_2.10-1.0-onejar.jar generated by 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
War es hilfreich?

Lösung

There is a bug in socko web server, and I have solved the bug on the following issue in GitHub.

GitHub: No resource for my/package in RestRegistry

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top