问题
I am getting the following error when running my Play Framework 2.2.x (Java) project:
Configuration error
Cannot register class [models.SomeClass] in Ebean server
The error messages displayed in the browser points me to the line ebean.default="models.*"
in my application.conf
, and the console tells me that I have a java.lang.VerifyError: Bad type on operand stack
in one of my methods. There is nothing special about the methods for which this happens, and it has happened for a handfull of methods now.
I have found out that the error can be avoided by using a static method instead: that is by replacing someObject.doJob()
by SomeClass.doJob(someObject)
. I have used this hack, and it works, but I am not very happy about making all my methods static when they should not be.
Has anyone encountered the same problem and found a way to fix it (without making the methods static)?
回答1:
SOLVED: It turned out that the methods with problems all referenced fields that were marked as final. Apparently, Play Framework / Ebean does not like final fields in Entity classes. After removing the final
keyword from these field, the problem went away.
回答2:
I am using play 2.3 and faced the same problem.
I created an abstract class and another one extending this abstract class. This cause an error. Looks like ebean consider every class extending an abstract class as a final class and throw the same error message.
Moving all the classes in another package removed the problem.
来源:https://stackoverflow.com/questions/20361370/cannot-register-class-in-ebean-server-play-framework-2-java