Alexander Chepurnoy

The Web of Mind

Play2+Morphia: How to Avoid 'Can't Parse Argument Number Interface' Error

| Comments

Trying to run Play2 + Morphia application, you can get such an error java.lang.IllegalArgumentException: can't parse argument number interface com.google.code.morphia.annotations.Id = @com.google.code.morphia.annotations.Id().

How to avoid it:

  • Add SLF4JExtension for Morphia : http://code.google.com/p/morphia/wiki/SLF4JExtension. Here is the example how to add SBT dependencies, but please mind difference beetwen com.google.code.morphia and com.github.jmkgreen.morphia (make appropriate changes): https://github.com/leodagdag/play2-morphia-plugin/blob/master/project/Build.scala .

  • Add 2 lines to init of your Global object(or beforeStart method)

      import com.google.code.morphia.logging.MorphiaLoggerFactory
      import com.google.code.morphia.logging.slf4j.SLF4JLogrImplFactory
      import play.api.GlobalSettings
    
      object Global extends GlobalSettings{
          MorphiaLoggerFactory.reset()
          MorphiaLoggerFactory.registerLogger(classOf[SLF4JLogrImplFactory])
      }
    

Comments