I've updated the play framework to version 2.1 in my application and it don't work more.
Here is a simple controller:
package controllers
import play.api._
import play.api.mvc._
import models.Country
import ru.circumflex.orm._
object Application extends Controller {
def index = Action {
val co = Country AS "co"
val q = SELECT (co.*) FROM (co)
val countries: Seq[Country] = q.list()
Ok(views.html.index(countries))
}
}
And here is model of a country:
package models
import ru.circumflex.orm.{TextField, Table, Record}
import java.util.regex.Pattern
class Country extends Record[String, Country] {
def PRIMARY_KEY = code
def relation = Country
def this(code: String, name: String) = {
this()
this.code := code
this.name := name
}
val code: TextField[Country] = "code".VARCHAR(2).NOT_NULL
val name = "name".TEXT.NOT_NULL
def cities = inverseMany(City.country)
override def toString = name.getOrElse("unknow")
}
object Country extends Country with Table[String, Country] {
val codeKey = UNIQUE(code)
val codeChk = CONSTRAINT("code_chk").CHECK("code IN ('ch', 'us', 'uk', 'fr', 'es', 'it', 'pt', 'by')")
val idx = "country_code_idx".INDEX("LOWER(code)").USING("btree").UNIQUE
validation.notNull(_.code)
.notEmpty(_.code)
.pattern(_.code, Pattern.compile("(?i:[a-z]{2})"))
}
When page is opened I get a follow error:
[error] application -
! @6d9l5j0i0 - Internal server error, for (GET) [/] ->
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.ExceptionInInitial
izerError]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.0]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$24.apply(
PlayDefaultUpstreamHandler.scala:314) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$24.apply(
PlayDefaultUpstreamHandler.scala:312) [play_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play
_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play
_2.10.jar:2.1.0]
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:222) ~[play_2.10.jar:2.1.0]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$
6.apply(Action.scala:109) ~[play_2.10.jar:2.1.0]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$
6.apply(Action.scala:109) ~[play_2.10.jar:2.1.0]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.0]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.sc
ala:108) ~[play_2.10.jar:2.1.0]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.sc
ala:106) ~[play_2.10.jar:2.1.0]
Caused by: java.lang.ExceptionInInitializerError: null
at controllers.Application$$anonfun$index$1.apply(Application.scala:18) ~[na:na]
at controllers.Application$$anonfun$index$1.apply(Application.scala:11) ~[na:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$11.apply(Action.scala:254) ~[play_2.10.jar:2
.1.0]
at play.api.mvc.ActionBuilder$$anonfun$apply$11.apply(Action.scala:254) ~[play_2.10.jar:2
.1.0]
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:217) ~[play_2.10.jar:2.1.0]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$
6.apply(Action.scala:109) ~[play_2.10.jar:2.1.0]
Caused by: java.lang.ClassNotFoundException: models.Country
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.7.0_09]
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.7.0_09]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_09]
at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.7.0_09]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.7.0_09]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.7.0_09]
Can anyone help me to solve this problem?
Circumflex 2.x doesnt appear to be built against scala 2.10 (which is needed for play 2.1).
The circumflex 3.0 is being built in 2.10, but its current only in snapshot. You can get the snapshot here:
https://oss.sonatype.org/content/repositories/snapshots/
Note that the package names have changed from ru.circumflex to pro.savant.circumflex so you may need to refactor your import statements.
I fixed it using these info: reference
First take last version of circumflex from Github:
git clone git://github.com/inca/circumflex.git
Following the suggestion, change line in the file orm/src/main/scala/relation.scala
line 55:
val _recordClass: Class[R] = Class.forName(
to
val _recordClass: Class[R] = this.getClass().getClassLoader().loadClass(
Now we can compile it, install and use in our Play 2.1 App
cd circumflex
mvn clean install
in case you need only one module:
cd circumflex
mvn clean install -pl <circumflex-orm> -am
Now edit your project/Build.scala
file to add dependency and local rep
val appDependencies = Seq(
"pro.savant.circumflex" % "circumflex-orm" % "3.1-SNAPSHOT"
)
val main = play.Project(appName, appVersion, appDependencies).settings(defaultScalaSettings:_*).settings(
resolvers += "Local Maven Repository" at "file:"+Path.userHome.absolutePath+"/.m2/repository"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.