1

我正在开发一个使用 Play2 和 Ebean 作为 ORM 的应用程序。由于以下错误,我无法启动我的应用程序:

[warn] c.a.e.s.c.DefaultServer - JMX beans for Ebean server [default] already registered. Will try unregister/registerEbean:server=default2,function=Logging
[warn] c.a.ebean.Ebean - Existing EbeanServer [default] is being replaced?
[error] application - 

! @6f14elgpb - Internal server error, for (GET) [/] ->

play.api.UnexpectedException: Unexpected exception[NullPointerException: null]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:150) ~[play_2.10.jar:2.1.2]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.2]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.2]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.1.2]
    at scala.util.Either$RightProjection.flatMap(Either.scala:523) ~[scala-library.jar:na]
Caused by: java.lang.NullPointerException: null
    at com.avaje.ebeaninternal.server.ddl.CreateTableVisitor.isDbColumnWritten(CreateTableVisitor.java:58) ~[avaje-ebeanorm-server.jar:na]
    at com.avaje.ebeaninternal.server.ddl.CreateTableColumnVisitor.visitOneImported(CreateTableColumnVisitor.java:117) ~[avaje-ebeanorm-server.jar:na]
    at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:109) ~[avaje-ebeanorm-server.jar:na]
    at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:73) ~[avaje-ebeanorm-server.jar:na]
    at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visitBean(VisitorUtil.java:62) ~[avaje-ebeanorm-server.jar:na]
    at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:36) ~[avaje-ebeanorm-server.jar:na]
[trace] play - No handler, got direct result: SimpleResult(500, Map(Content-Type -> text/html; charset=utf-8))

我不明白发生了什么,服务器启动良好,我试图重新启动 mysql 但没有任何改变。这似乎是来自 Ebean DDL 生成器的错误,但我该如何调试它?

谢谢你的帮助。

编辑:如果我在 application.conf 中禁用进化插件

# Evolutions
# ~~~~~
# You can disable evolutions if needed
evolutionplugin=disabled

我的应用程序启动(但数据库未更新...)

编辑 2:我在应用程序级别激活了 TRACE 日志并更新了堆栈跟踪,以下几行呢:

[warn] c.a.e.s.c.DefaultServer - JMX beans for Ebean server [default] already registered. Will try unregister/registerEbean:server=default2,function=Logging
[warn] c.a.ebean.Ebean - Existing EbeanServer [default] is being replaced?
4

1 回答 1

2

好的,我找到了问题所在。我有一个带有注释的客户实体:

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(unique = true)
@NotNull
public User user;

如果我name = "user_id",在 JoinColumn 注释中添加,错误就不会再发生了......所以这行得通:

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "user_id", unique = true)
@NotNull
public User user;

但在所有情况下,我的 user_id 列上的唯一约束都没有应用到数据库中。你们有一个想法吗?这是 Ebean 的限制吗?

谢谢。

于 2013-07-17T02:00:58.087 回答