Reputation: 451
If try to run my application which uses akka it shows me the following error:
play.api.i18n.Messages$MessagesParser$$anon$1: Configuration error[`=' expected but `
' found]
at play.api.i18n.Messages$MessagesParser.parse(Messages.scala:219) ~[play_2.10- 2.2.1.jar:2.2.1]
at play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:286) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:285) ~[play_2.10-2.2.1.jar:2.2.1]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.immutable.List.foreach(List.scala:318) ~[scala-library.jar:na]
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.AbstractTraversable.map(Traversable.scala:105) ~[scala-library.jar:na]
at play.api.i18n.MessagesPlugin.play$api$i18n$MessagesPlugin$$loadMessages(Messages.scala:285) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.i18n.MessagesPlugin.messages$lzycompute(Messages.scala:296) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.i18n.MessagesPlugin.messages(Messages.scala:292) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.i18n.MessagesPlugin.onStart(Messages.scala:309) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88) ~[play_2.10-2.2.1.jar:2.2.1]
at scala.collection.immutable.List.foreach(List.scala:318) ~[scala-library.jar:na]
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.Play$$anonfun$start$1.apply(Play.scala:88) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.Play$$anonfun$start$1.apply(Play.scala:88) ~[play_2.10-2.2.1.jar:2.2.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.Play$.start(Play.scala:87) ~[play_2.10-2.2.1.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:139) ~[play_2.10-2.2.1.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.1.jar:2.2.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.1.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10-2.2.1.jar:2.2.1]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:110) ~[play_2.10-2.2.1.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:102) ~[play_2.10-2.2.1.jar:2.2.1]
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 scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) ~[scala-library.jar:na]
I built a case class with the purpose to send it as a Message to an Actor:
package messages
object ErrorHandlerMessages {
case class Error (message:String, exception:Exception)
}
When I run my application and try to send the message to my actor...:
class ErrorHandlerActor extends Actor {
val log = Logging(context.system, this)
def receive: Receive = {
case e:Error => handleError(e)
case _ => handleError(Error("UNEXPECTED ERROR!",new Exception("UNEXPECTED ERROR! The Error Handler received an unknown message!")))
}
def handleError(e:Error):SimpleResult = {
log.error(e.message,e.exception)
BadRequest(Json.obj("status" ->"Error", "message" -> e.message))
}
}
... it throws the error you see above.
When I change the code a bit so my actor receives a String it works well. Can somebody tell me what I am missing?
Thanks in advance
Here the piece of code that works:
on the sending side ->
Await.result(errorHandlerActor ? "Couldnt validate json input correctly!",timeout.duration).asInstanceOf[SimpleResult]
on the receiving side ->
class ErrorHandlerActor extends Actor {
val log = Logging(context.system, this)
def receive: Receive = {
case e:String => handleError(e)
case _ => handleError("UNEXPECTED ERROR!"/*,new Exception("UNEXPECTED ERROR! The Error Handler received an unknown message!")*/)
}
def handleError(e:String) = {
log.error(e)
sender ! BadRequest(Json.obj("status" ->"Error"))
}
}
Here the messages file which is loaded:
# Default messages
# --- Constraints
constraint.required=Required
constraint.min=Minimum value: {0}
constraint.max=Maximum value: {0}
constraint.minLength=Minimum length: {0}
constraint.maxLength=Maximum length: {0}
constraint.email=Email
# --- Formats
format.date=Date (''{0}'')
format.numeric=Numeric
format.real=Real
# --- Errors
error.invalid=Invalid value
error.invalid.java.util.Date=Invalid date value
error.required=This field is required
error.number=Numeric value expected
error.real=Real number value expected
error.real.precision=Real number value with no more than {0} digit(s) including {1} decimal(s) expected
error.min=Must be greater or equal to {0}
error.min.strict=Must be strictly greater than {0}
error.max=Must be less or equal to {0}
error.max.strict=Must be strictly less than {0}
error.minLength=Minimum length is {0}
error.maxLength=Maximum length is {0}
error.email=Valid email required
error.pattern=Must satisfy {0}
error.expected.date=Date value expected
error.expected.date.isoformat=Iso date value expected
error.expected.jodadate.format=Joda date value expected
error.expected.jsarray=Array value expected
error.expected.jsboolean=Boolean value expected
error.expected.jsnumber=Number value expected
error.expected.jsobject=Object value expected
error.expected.jsstring=String value expected
error.expected.jsnumberorjsstring=String or number expected
error.expected.keypathnode=Node value expected
error.path.empty=Empty path
error.path.missing=Missing path
error.path.result.multiple=Multiple results for the given path
Upvotes: 0
Views: 753
Reputation: 451
After a very long period of time searching for that error it is finally solved thanks to "vptheron" who pointed me in the right direction.
I put multiple custom "messages" files with different suffixes (en,de,fr etc.) and the default one without suffix to my "conf" directory which usually end up in the classpath after compilation, but the only file which wasnt there under ../target/scala-2.10/classes was a "messages" file.
I simply forgot that I created a package also called "messages" in the classpath (weeks ago). So this was conflicting while the compiler tried to copy the messages file.
Thanks again to vptheron. I hope this will help someone in the future.
Upvotes: 1
Reputation: 7466
The exception seems to be due to the internationalisation plugin. Especially here:
at play.api.i18n.MessagesPlugin.play$api$i18n$MessagesPlugin$$loadMessages(Messages.scala:285) ~[play_2.10-2.2.1.jar:2.2.1] at play.api.i18n.MessagesPlugin.messages$lzycompute(Messages.scala:296) ~[play_2.10-2.2.1.jar:2.2.1] at play.api.i18n.MessagesPlugin.messages(Messages.scala:292) ~[play_2.10-2.2.1.jar:2.2.1] at play.api.i18n.MessagesPlugin.onStart(Messages.scala:309) ~[play_2.10-2.2.1.jar:2.2.1]
Line 285 in Messages.scala is trying to load messages from a file
private def loadMessages(file: String): Map[String, String] = {
app.classloader.getResources(file).asScala.toList.reverse.map { messageFile =>
new Messages.MessagesParser(messageFile.asInput, messageFile.toString).parse.map { message =>
message.key -> message.pattern
}.toMap
}.foldLeft(Map.empty[String, String]) { _ ++ _ }
}
Can you add breakpoints in this function to see what's the malformed file that the plugin is trying to read?
FYI: the default behavior is to try to load all files with the pattern "messages.lang" where 'lang' is something like 'en', 'fr', etc. (e.g. messages.en, messages.it)
Upvotes: 3