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:
public static String buildUrl(String document) {
return controllers.routes.Documents.display(document.toLowerCase()).absoluteURL(Http.Context.current().request());
}
you can just add
@Transient
annotation to method and it works!
I had this same problem today. I tried to apply the same logic suggested above (use a static function for the problem method) but to no avail. I restarted play, cleaned, recompiled, and the problem went away.
Here are the play commands I used.
exit
play
clean
run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With