我在SBT版本中添加了这些Scalac选项:
scalacOptions ++= Seq("-unchecked", "-deprecation","-feature"),
但是我再也无法访问我的Play 2.1网络应用程序了。
这是我构建的唯一修改部分,如果我删除它,它再次正常工作。
这很奇怪,因为应用程序似乎正在运行(我看到启动日志,预定作业......),但是尝试从浏览器访问它会给我播放错误页面:
Cannot init the Global object
No source available, here is the exception stack trace:
->java.lang.ExceptionInInitializerError:
Global$.<init>(Global.scala:17)
Global$.<clinit>(Global.scala)
sun.misc.Unsafe.ensureClassInitialized(Native Method)
sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
java.lang.reflect.Field.getFieldAccessor(Field.java:930)
java.lang.reflect.Field.get(Field.java:372)
play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$scalaGlobal(Application.scala:37)
play.api.DefaultApplication.play$api$WithDefaultGlobal$$scalaGlobal$lzycompute(Application.scala:383)
play.api.DefaultApplication.play$api$WithDefaultGlobal$$scalaGlobal(Application.scala:383)
play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1$$anonfun$apply$5.apply(Application.scala:52)
play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1$$anonfun$apply$5.apply(Application.scala:52)
scala.Option.getOrElse(Option.scala:120)
play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:52)
play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:51)
play.utils.Threads$.withContextClassLoader(Threads.scala:18)
play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:50)
play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:383)
play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:383)
play.api.WithDefaultGlobal$class.global(Application.scala:66)
play.api.DefaultApplication.global(Application.scala:383)
play.api.WithDefaultConfiguration$class.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:80)
play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration$lzycompute(Application.scala:383)
play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:383)
play.api.WithDefaultConfiguration$class.configuration(Application.scala:82)
play.api.DefaultApplication.configuration(Application.scala:383)
play.api.Application$class.$init$(Application.scala:268)
play.api.DefaultApplication.<init>(Application.scala:383)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anon$1.<init>(ApplicationProvider.scala:128)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:128)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:114)
scala.Option.map(Option.scala:145)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:114)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112)
scala.util.Either$RightProjection.flatMap(Either.scala:523)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:112)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:722)
我的Global.scala看起来像这样:
object Global extends GlobalSettings {
// TODO use cake pattern injection?
val searchService: SearchService = StampleApplication.get.searchService
val breadcrumbService: BreadcrumbService = StampleApplication.get.breadcrumbService
override def onStart(app: Application) {
Logger.info("Application has started")
startElasticSearchIndexationScheduling
startBreadcrumbUpdaterJob
}
override def onStop(app: Application) {
Logger.info("Application shutdown...")
}
// TODO externaliser delais des jobs dans la conf play?
def startElasticSearchIndexationScheduling = {
Akka.system.scheduler.schedule(30 seconds , 30 seconds) {
Logger.info("Indexation job triggered")
searchService.indexUnindexedStamples
searchService.indexUnindexedUsers
}
}
def startBreadcrumbUpdaterJob = {
Akka.system.scheduler.schedule(30 seconds, 30 seconds) {
Logger.info("Breadcrumb updated job triggered")
breadcrumbService.updateChildsBreadcrumbForFlaggedCategories
Logger.info("Breadcrumb updated (with recursion!) job triggered")
breadcrumbService.recompteAllFlaggedWithRecursion
}
}
}
Global $。(Global.scala:17)似乎引用了这一行:
val searchService: SearchService = StampleApplication.get.searchService
其他来源是:
object StampleApplication {
val get: CakeApplication = {
println("Building stample cake application")
// Inject properties here
new CakeConfiguration().buildApplication
}
}
trait CakeApplication
extends ServiceLayer
with RepositoryLayer
trait ServiceLayer
extends RepositoryLayer
with DefaultUserServiceComponent
with DefaultCategoryServiceComponent
with DefaultStampleServiceComponent
with DefaultAclServiceComponent
with DefaultFileServiceComponent
with DefaultApiCallServiceComponent
with DefaultBreadcrumbServiceComponent
with DefaultSearchServiceComponent
with DefaultRelationshipServiceComponent
with DefaultSharingServiceComponent
with DefaultAuthCodeServiceComponent
with DefaultNotificationServiceComponent
with DefaultEventServiceComponent
with DefaultCommentServiceComponent
trait RepositoryLayer
extends MongoUserRepositoryComponent
with MongoCategoryRepositoryComponent
with MongoCategorySharingRepositoryComponent
with MongoStampleRepositoryComponent
with MongoFileRepositoryComponent
with MongoApiCallRepositoryComponent
with MongoRelationshipRepositoryComponent
with MongoSharingRepositoryComponent
with MongoNotificationRepositoryComponent
with SalatDAOFactoryComponent
with CollectionProviderComponent
trait CollectionProviderComponent {
def collectionProvider:MongoCollectionProvider
}