Search code examples
mysqlscalaexceptionplayframework-2.3sorm

Exception in setup sorm


I cannot initialize project with sorm framework with mysql. I have scala 2.10.4. I have configured my mysql database in application.conf. I add DB object in my models package:

package models

import sorm._

object DB extends Instance(
    entities = Set(Entity[User]()),
    url = "jdbc:mysql://localhost:3306/play_test?useUnicode=true&characterEncoding=UTF-8",
    user = "root"
)

but I have received this exception

[RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class models.DB$]

Help me please who know what is it.


Solution

  • It seems your object should be in package models. Either the code sample is not complete there, or you should have to add package models before you object declaration.

    package models
    
    import sorm._
    
    object DB ...