Unable to register class on Ebean server (Play Framework 2 - Java)

When starting the Play Framework 2.2.x (Java) project, the following error occurs:

Configuration error Cannot register class [models.SomeClass] in Ebean server 

The error messages displayed in the browser point me to the line ebean.default="models.*" In my application.conf , and the console tells me that I have 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 this has happened for several methods.

I found that errors can be avoided by using the static method instead: replacing someObject.doJob() with SomeClass.doJob(someObject) . I used this hack and it works, but I'm not very happy that all my methods are static when they should not be.

Has anyone encountered the same problem and found a way to fix it (without making static methods)?

+6
source share
2 answers

SOLVED: It turned out that methods with problems are associated with all fields marked as final. Apparently, the Play Framework / Ebean does not like the final fields in Entity classes. After removing the final keyword from this field, the problem disappeared.

+5
source

I am using play 2.3 and am facing the same problem.

I created an abstract class, and another extended this abstract class. This causes an error. It seems that ebean treats each class, extending the abstract class as a finite class and causing the same error message.

Moving all classes in another package fixed the problem.

-1
source

Source: https://habr.com/ru/post/959273/


All Articles