使用Spring,Play Framework,Hibernate和MySql时出错

时间:2014-10-01 23:55:44

标签: java spring hibernate scala playframework

我很长时间试图将架构播放 - 弹簧 - 休眠,但每次我都尝试以下错误:

我经常尝试重置和重新配置。

我错过了一些依赖吗?

此架构是否有任何问题?

我正在使用播放网站中留下的示例:

https://github.com/jamesward/play2bars/tree/java-spring

我必须修改要运行的项目的依赖项。

但是当我总是提出请求时,当我调用方法Form form = Form.form(Bar.class).bindFromRequest()时,它会生成发布的错误。

>    [info] Compiling 2 Java sources to C:\Users\Minhoca\Desktop\sistem\target\scala-
2.10\classes...
[info] play - database [default] connected at jdbc:h2:db
[info] play - Application started (Dev)
Hibernate: select bar0_.id as id0_, bar0_._ebean_intercept as column2_0_, bar0_.
name as name0_ from Bar bar0_
Uncaught error from thread [play-akka.actor.default-dispatcher-4] shutting down
JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[play]
java.lang.ExceptionInInitializerError
        at play.data.Form.bind(Form.java:321)
[ERROR] [10/01/2014 17:10:15.168] [play-akka.actor.default-dispatcher-4] [ActorS
ystem(play)] Uncaught error from thread [play-ak        at play.data.Form.bindFr
omRequest(Form.java:216)
ka.actor.default-dispatcher-4] shutting down JVM since 'akka.jvm-exit-on-fatal-e
rror' is enabled
        at controllers.Application.addBar(Application.java:23)
java.lang.ExceptionInInitializerError
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73)
        at play.data.Form.bind(Form.java:321)
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73)
        at play.data.Form.bindFromRequest(Form.java:216)
        at play.core.Router$HandlerInvoker$$anon$7$$anon$2.invocation(Router.sca
la:183)
        at controllers.Application.addBar(Application.java:23)
        at play.core.Router$Routes$$anon$1.invocation(Router.scala:377)
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73)
        at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:56)
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73)
        at play.GlobalSettings$1.call(GlobalSettings.java:64)
        at play.core.Router$HandlerInvoker$$anon$7$$anon$2.invocation(Router.sca
la:183)
        at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:91)
        at play.core.Router$Routes$$anon$1.invocation(Router.scala:377)
        at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:90)
        at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:56)
        at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.sc
ala:82)
        at play.GlobalSettings$1.call(GlobalSettings.java:64)
        at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.sc
ala:82)
        at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:91)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:90)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249)
        at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.sc
ala:82)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.sc
ala:82)
        at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.sca
la:37)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:42)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(Abst
ractDispatcher.scala:386)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.sca
la:37)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool
.java:1339)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:42)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:19
79)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(Abst
ractDispatcher.scala:386)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThre
ad.java:107)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
Caused by: java.lang.IllegalArgumentException: Type must not be null
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool
.java:1339)
        at org.springframework.util.Assert.notNull(Assert.java:112)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:19
79)
        at org.springframework.core.convert.TypeDescriptor.valueOf(TypeDescripto
r.java:493)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThre
ad.java:107)
        at org.springframework.format.support.FormattingConversionService$Printe
rConverter.<init>(FormattingConversionService.java:123)Caused by: java.lang.Ille
galArgumentException: Type must not be null

        at org.springframework.util.Assert.notNull(Assert.java:112)
        at org.springframework.format.support.FormattingConversionService.addFor
>matterForFieldType(FormattingConversionService.java:80) at org.springframework.c
ore.convert.TypeDescriptor.valueOf(TypeDescriptor.java:493)

        at org.springframework.format.support.FormattingConversionService$Printe
>rConverter.<init>(FormattingConversionService.java:123) at play.data.format.Form
atters.register(Formatters.java:204)

        at play.data.format.Formatters.<clinit>(Formatters.java:101)
        at org.springframework.format.support.FormattingConversionService.addFor
>matterForFieldType(FormattingConversionService.java:80) ... 23 more

        at play.data.format.Formatters.register(Formatters.java:204)
        at play.data.format.Formatters.<clinit>(Formatters.java:101)
        ... 23 more

>[error] a.a.ActorSystemImpl - Uncaught error from thread [play-akka.actor.defaul
t-dispatcher-4] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enable
d
java.lang.ExceptionInInitializerError: null
        at play.data.Form.bind(Form.java:321) ~[play-java_2.10.jar:2.2.4]
        at play.data.Form.bindFromRequest(Form.java:216) ~[play-java_2.10.jar:2.
2.4]
        at controllers.Application.addBar(Application.java:23) ~[classes/:na]
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73) ~[classes/:na]
        at Routes$$anonfun$routes$1$$anonfun$applyOrElse$3$$anonfun$apply$7.appl
y(routes_routing.scala:73) ~[classes/:na]
        at play.core.Router$HandlerInvoker$$anon$7$$anon$2.invocation(Router.sca
la:183) ~[play_2.10.jar:2.2.4]
Caused by: java.lang.IllegalArgumentException: Type must not be null
        at org.springframework.util.Assert.notNull(Assert.java:112) ~[spring-cor
e-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.core.convert.TypeDescriptor.valueOf(TypeDescripto
r.java:493) ~[spring-core-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.format.support.FormattingConversionService$Printe
rConverter.<init>(FormattingConversionService.java:123) ~[spring-context-4.0.0.R
ELEASE.jar:4.0.0.RELEASE]
        at org.springframework.format.support.FormattingConversionService.addFor
matterForFieldType(FormattingConversionService.java:80) ~[spring-context-4.0.0.R
ELEASE.jar:4.0.0.RELEASE]
        at play.data.format.Formatters.register(Formatters.java:204) ~[play-java
_2.10.jar:2.2.4]
        at play.data.format.Formatters.<clinit>(Formatters.java:101) ~[play-java
_2.10.jar:2.2.4]




> import sbt._
>import Keys._
>import play.Project._

>object ApplicationBuild extends Build {

>    val appName         = "play2bars-java-spring"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      javaCore,
      "com.h2database" % "h2" % "1.3.168",
      "org.springframework" % "spring-core" % "4.0.0.RELEASE",
      "org.springframework" % "spring-expression" % "4.0.0.RELEASE",
      "org.springframework" % "spring-context" % "4.0.0.RELEASE",
      "org.springframework" % "spring-orm" % "4.0.0.RELEASE",
      "org.springframework" % "spring-jdbc" % "4.0.0.RELEASE",
      "org.springframework" % "spring-tx" % "4.0.0.RELEASE",
      "org.springframework" % "spring-test" % "4.0.0.RELEASE" % "test",
      "org.hibernate" % "hibernate-entitymanager" % "4.1.9.Final",
      "cglib" % "cglib" % "2.2.2"
    )

    val main = play.Project(appName, appVersion, appDependencies).settings(
      // Add your own project settings here      
    )

>}

1 个答案:

答案 0 :(得分:0)

我更新了我的参考资料,现在一切正常。

我的文章:

val appDependencies = Seq(
      javaCore,
      "com.h2database" % "h2" % "1.4.181",
       "org.springframework" % "spring-context" % "4.1.1.RELEASE",
       "org.springframework" % "spring-expression" % "3.2.1.RELEASE",
       "org.springframework" % "spring-core" % "4.1.1.RELEASE",
       "org.springframework" % "spring-beans" % "4.1.1.RELEASE",
      "org.springframework" % "spring-aop" % "4.1.1.RELEASE",
      "org.springframework" % "spring-orm" % "4.1.1.RELEASE",
      "org.springframework" % "spring-jdbc" % "4.1.1.RELEASE",
      "org.springframework" % "spring-tx" % "4.1.1.RELEASE",
      "org.springframework" % "spring-test" % "4.1.1.RELEASE" % "test",
      "org.springframework" % "spring-web" % "4.1.1.RELEASE",
      "org.springframework" % "spring-webmvc" % "4.1.1.RELEASE",
      "commons-dbcp" % "commons-dbcp" % "1.4",
      "commons-collections" % "commons-collections" % "3.2.1",
      "commons-logging" % "commons-logging" % "1.1.3",
      "org.hibernate" % "hibernate-c3p0" % "4.3.6.Final",
      "org.hibernate" % "hibernate-core" % "4.3.6.Final",
      "org.hibernate" % "hibernate-entitymanager" % "4.3.6.Final",
      "cglib" % "cglib" % "2.2.2",
      "mysql" % "mysql-connector-java" % "5.1.28"
    )