我正在尝试将我的应用程序从 Play 2.0.3 迁移到最新版本的 Play Framework (2.1.3) 和 play2-elasticsearch 插件。
根据插件自述文件我使用 0.7-SNAPSHOT 版本。
我的 sbt 是:
"com.github.cleverage" % "elasticsearch_2.9.1" % "0.4.1"
并成为:
"com.clever-age" % "play2-elasticsearch" % "0.7-SNAPSHOT"
我在应用程序启动时收到 NullPointerException :
play.api.Configuration$$anon$1: Configuration error[Cannot register class [models.indexing.ClientIndex] in Ebean server]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:81) ~[play_2.10.jar:2.1.3]
at play.api.Configuration.reportError(Configuration.scala:559) ~[play_2.10.jar:2.1.3]
at play.Configuration.reportError(Configuration.java:298) ~[play_2.10.jar:2.1.3]
at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:71) ~[play-java-ebean_2.10.jar:2.1.3]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:68) ~[play_2.10.jar:2.1.3]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:68) ~[play_2.10.jar:2.1.3]
at scala.collection.immutable.List.foreach(List.scala:309) ~[scala-library.jar:na]
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:68) ~[play_2.10.jar:2.1.3]
at play.api.Play$$anonfun$start$1.apply(Play.scala:68) ~[play_2.10.jar:2.1.3]
at play.api.Play$$anonfun$start$1.apply(Play.scala:68) ~[play_2.10.jar:2.1.3]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.3]
at play.api.Play$.start(Play.scala:67) ~[play_2.10.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:141) ~[play_2.10.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.3]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.1.3]
at scala.util.Either$RightProjection.flatMap(Either.scala:523) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104) ~[play_2.10.jar:2.1.3]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[scala-library.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_09]
at java.lang.Thread.run(Unknown Source) [na:1.7.0_09]
Caused by: java.lang.ExceptionInInitializerError: null
at com.github.cleverage.elasticsearch.Index.getIndexPath(Index.java:37) ~[play2-elasticsearch-0.7-SNAPSHOT.jar:0.7-SNAPSHOT]
at com.github.cleverage.elasticsearch.Index$Finder.<init>(Index.java:144) ~[play2-elasticsearch-0.7-SNAPSHOT.jar:0.7-SNAPSHOT]
at models.indexing.ClientIndex.<clinit>(ClientIndex.java:18) ~[na:na]
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_09]
at java.lang.Class.forName(Unknown Source) ~[na:1.7.0_09]
at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:69) ~[play-java-ebean_2.10.jar:2.1.3]
... 21 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.github.cleverage.elasticsearch.IndexService.<clinit>(IndexService.java:43) ~[play2-elasticsearch-0.7-SNAPSHOT.jar:0.7-SNAPSHOT]
... 27 common frames omitted
所以我认为在类似问题中解释的案例不是我的案例。
请帮我解决这个问题。
更新:
我的弹性搜索配置:
## ElasticSearch Configuration
##############################
## define local mode or not
elasticsearch.local=true
## list clients
# ex : elasticsearch.client="192.168.0.46:9300,192.168.0.47:9300"
## Name of the index
elasticsearch.index.name="play2-elasticsearch"
## Custom settings to apply when creating the index (optional)
# elasticsearch.index.settings="{ analysis: { analyzer: { my_analyzer: { type: \"custom\", tokenizer: \"standard\" } } } }"
## define package or class separate by commas for loading @IndexType and @IndexMapping information
elasticsearch.index.clazzs="models.*"
## show request & result json of search request in log
elasticsearch.index.show_request=true