EBean: java.lang.IllegalStateException: Bean class models.User is not enhanced?

时间:2016-02-12 20:12:13

标签: mysql playframework playframework-2.0 ebean

I have a Play 2.4.6 app that was working fine until two days ago. Since yesterday, I got this error:

[[37minfo] - application - Creating Pool for datasource 'default'
[[31merror] - com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager - Error in deployment
java.lang.IllegalStateException: Bean class models.User is not enhanced?
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:1405) ~[avaje-ebeanorm-6.8.1.jar:na]

I already looked for solutions but I am still getting that error. Even, I tried using plugin 2.0

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "2.0.0") 

How can I fix it?

Thank you in advance,

Update: In the end, I rewrote the code, removed EBean, and began to use Play Framework's database pool and JDBC's PreparedStatement. Works fine. I will leave this question here, hoping it helps someone else.

4 个答案:

答案 0 :(得分:2)

Check the following:

  1. Ensure @Entity annotation is specified on the User class.
  2. Ensure application.conf has the ebean package configured for your datasource: <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0"> <description><![CDATA[]]></description> <display-name></display-name> <enterprise-beans> <session id=""> <description><![CDATA[]]></description> <ejb-name></ejb-name> <env-entry> <env-entry-name></env-entry-name> <env-entry-type></env-entry-type> <env-entry-value><![CDATA[]]></env-entry-value> </env-entry>
  3. Ensure ebean.default=["models.*"] is in your plugin.sbt file.
  4. Ensure you have PlayEbean enabled in build.sbt: addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

答案 1 :(得分:1)

如果您想再次使用ebean进行尝试,这对我来说是个窍门

https://www.youtube.com/watch?v=o4kmglM48Vc

答案 2 :(得分:0)

如果您try all of the given solutionscouldn't解决了该问题,请检查项目的JDK版本。

Java11存在某种问题。 尝试Java8或更低版本。

答案 3 :(得分:0)

根据您使用的播放框架的版本,可能需要更改

ebean.default= ["models.*", "another.models.*"]

ebean.default="models.*, another.models.*"

您可以在此处找到更多详细信息: https://github.com/playframework/play-ebean/issues/18

此外,您将需要为每个需要eBean增强器的模块配置playEbeanModels。例如:

    lazy val domainModel = (project in file("domain-model")).enablePlugins(PlayJava, PlayEbean).settings(Seq(
      libraryDependencies ++= Seq(
        "org.projectlombok" % "lombok" % "1.18.4",
        "com.h2database" % "h2" % "1.4.197",
        guice),
      playEbeanModels in Compile := Seq("com.mycompany.model.*"), // this should match the package name from above ebean.default="com.mycompany.model.*
      playEbeanDebugLevel := 4
)

在这里也可以找到一些解释: https://github.com/playframework/play-ebean/issues/25