Strict Standards: Declaration of HTML_Menu3::_findNodeType() should be compatible with HTML_Menu::_findNodeType($nodeId, &$nodeUrl, $level) in /var/www/wi-fizzle.com/lib/HTML/Menu3.php on line 49
Wi-Fizzle.com | Scala Regex matching exception
Wi-Fizzle.com - Putting the fizzle in Wi-Fi since 2005 .. (yes, this was a poor choice for a domain name)

<div class="news_item">#459<div class="news_title">Scala Regex matching exception

Posted by dandriff on Saturday September 01, 2012@03:18PM

Here is the code fragment:

 trait ElasticSearchIndexed[T] {
 
     private val _containsIdPattern = """^.*[^\]"id" *:.*$""".r
     private val _idIntegralPattern = """^[1-9][0-9]*$""".r
 
     /**
      * NB: If search hit result `id' field not present in json, then one will be inferred and inserted.
      */
     implicit def searchHitToT(hit: SearchHit)(implicit manifest: Manifest[T]): T = {
 
         val source = hit.sourceAsString
 
         val cleanedSource: String = source match {
 
             case _containsIdPattern(p) =>
                 println("P=" + p)
                 source
 
             case _ => hit.id.toString match {
 
                 case _idIntegralPattern(p) => source.replaceFirst("\{", """{"id":""" + hit.id.toLong + ",")
 
                 case _ => source.replaceFirst("\{", """{"id":"""" + hit.id.replaceAll("\"", "\\\"") + """",""")
             }
         }
         println("A: " + source)
         println("B: " + cleanedSource)
 
         parse[T](cleanedSource)
     }
 

The runtime JVM exception was like this:

 play.api.Application$$anon$1: Execution exception [[AbstractMethodError: com.company.models.Group$.com$company$models$ElasticSearchIndexed$_setter_$com$company$models$ElasticSearchIndexed$$_containsIdPattern_$eq(Lscala/util/matching/Regex;)V]]
     at play.api.Application.handleError(Application.scala:144) ~[play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:121) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:108) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
     at play.core.ActionInvoker.apply(Invoker.scala:106) [play_2.9.1-2.1-07132012.jar:2.1-07132012]
     at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
 Caused by: java.lang.AbstractMethodError: com.company.models.Group$.com$company$models$ElasticSearchIndexed$_setter_$com$company$models$ElasticSearchIndexed$$_containsIdPattern_$eq(Lscala/util/matching/Regex;)V
     at com.company.models.ElasticSearchIndexed$class.$init$(ElasticSearchIndexed.scala:18) ~[classes/:na]
     at com.company.models.Group$.<init>(Group.scala:70) ~[classes/:na]
     at com.company.models.Group$.<clinit>(Group.scala) ~[classes/:na]
     at com.company.services.impl.GroupSearchService$$anonfun$4.apply(GroupSearchService.scala:79) ~[classes/:na]
     at com.company.services.impl.GroupSearchService$$anonfun$4.apply(GroupSearchService.scala:79) ~[classes/:na]
     at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]

Solution: Clean and recompile your play-framework project

 play clean
 play compile

Tags:

  • AbstractMethodError
  • scala/util/matching/Regex
  • Execution exception
  • Execution exception [[AbstractMethodError "scala/util/matching/Regex"
  • Play-framework 2.0.3
  • Play-framework 2.0.x
  • Play-framework 2.x
  • SBT
  • Simple Build Tool
  • Scala
  • Regex
  • Regular expressions
  • JVM
  • Play