Ebeans使用自定义消息验证奇怪的行为

时间:2013-10-31 09:25:49

标签: java playframework-2.0 ebean

我得到了简单的验证,如:

@Column(length=6)
@Pattern(regexp = "[0-9]{2}( |-)?[0-9]{3}", message = Errors.kod_pocztowy)
private String kod_pocztowy;

但它返回了奇怪的错误:

failed: java.lang.NoClassDefFoundError: javax/el/ELContext
[error]     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)
[error]     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateMessage(ResourceBundleMessageInterpolator.java:187)
[error]     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolate(ResourceBundleMessageInterpolator.java:115)
[error]     at org.hibernate.validator.internal.engine.ValidationContext.interpolate(ValidationContext.java:370)
[error]     at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolation(ValidationContext.java:284)
[error]     at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolations(ValidationContext.java:246)
[error]     at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:289)
[error]     at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:133)
[error]     at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
[error]     at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85)
[error]     at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:478)
[error]     at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424)
[error]     at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388)
[error]     at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340)
[error]     at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:158)

当我将消息属性更改为文本时:

@Column(length=6)
@Pattern(regexp = "[0-9]{2}( |-)?[0-9]{3}", message = "Now its ok")
private String kod_pocztowy;

然后一切似乎都没问题。有什么问题?有人可以帮我解释一下吗?

1 个答案:

答案 0 :(得分:0)

好的,我自己找到了。使用类似{}的字符会导致Ebean从类加载消息,并且此消息与该类相关。