Here’s my model Document :
@Entity
@Table(name = "documents")
public class Document extends Model {
@Id
public Long id;
@Constraints.Required
@Formats.NonEmpty
@Column(nullable=false)
public String document;
public static Model.Finder<Long,Document> find = new Model.Finder(Long.class, Document.class);
// Will return an absolute URL to this document
public String getUrl() {
return controllers.routes.Documents.display(document.toLowerCase()).absoluteURL(Http.Context.current().request());
}
}
The problem is, it throws a VerifyError exception at compile time, and the only thing I found to avoid it, is comment the line and replace it with return null, which is not very effective.
Here’s the stack trace for that exception:
Caused by: java.lang.VerifyError: Bad type on operand stack in method models.Document.getUrl()Ljava/lang/String; at offset 13
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_05]
at java.lang.Class.forName(Class.java:264) ~[na:1.7.0_05]
at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:69) ~[play_2.9.1.jar:2.0.2]
What is this error and how can I avoid it without losing the getUrl method?
I think Ebean is trying to do some magic here.
I suggest to use a static function: