无法在Ebean服务器中注册类(Play Framework 2 - Java) [英] Cannot register class in Ebean server (Play Framework 2 - Java)

查看:189
本文介绍了无法在Ebean服务器中注册类(Play Framework 2 - Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行Play Framework 2.2.x(Java)项目时出现以下错误:

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

浏览器中显示的错误消息指向我在我的 application.conf 中的 ebean.default =models。*行,控制台告诉我我在我的一个方法中有一个 java.lang.VerifyError:操作数堆栈上的错误类型。发生这种情况的方法没有什么特别之处,现在已经发生了一些方法。

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.

我发现可以通过使用来避免错误一个静态方法:通过 SomeClass.doJob(someObject)替换 someObject.doJob()。我已经使用过这个hack,它可以正常工作,但我不是很高兴我的所有方法都不应该是静态的。

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)?

推荐答案

解决:事实证明所有方法都有问题引用的标记为final的字段。显然,Play Framework / Ebean不喜欢Entity类中的final字段。从这些字段中删除 final 关键字后,问题就消失了。

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.

这篇关于无法在Ebean服务器中注册类(Play Framework 2 - Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆