Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorm and Play Framework 2.1

I'm trying to use Sorm into a play framework project. I'm using the 2.1 version which uses Scala 2.10. The problem is that my classes are not recognized by Sorm, I get a ClassNotFoundException

Here is what I used:

package models

case class User(val name: String)

object Db extends Instance (
  entities = Set(Entity[User]()),
  url = "jdbc:h2:mem:test"
)

In my controller:

import models.{Db,User}

object Application extends Controller {
  def index = Action {
    Db.save(User("test")) // Error at this line
    Ok("saved")
  }
}

And the exception:

play.api.Application$$anon$1: Execution exception[[ClassNotFoundException: models.User]]
    at play.api.Application$class.handleError(Application.scala:279) ~[play_2.10.jar:2.1-RC1]
    at play.api.DefaultApplication.handleError(Application.scala:373) [play_2.10.jar:2.1-RC1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$10$$anonfun$apply$27.apply(PlayDefaultUpstreamHandler.scala:296) [play_2.10.jar:2.1-RC1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$10$$anonfun$apply$27.apply(PlayDefaultUpstreamHandler.scala:294) [play_2.10.jar:2.1-RC1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
Caused by: java.lang.ClassNotFoundException: models.User
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_09]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_09]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_09]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_09]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_09]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ~[na:1.7.0_09]

Any idea how I can make this work ?

like image 672
vdebergue Avatar asked Nov 04 '22 07:11

vdebergue


1 Answers

This was an incompatibility issue, which is now fixed since release 0.3.7. Cheers!

like image 116
Nikita Volkov Avatar answered Nov 09 '22 17:11

Nikita Volkov