码迷,mamicode.com
首页 > 编程语言 > 详细

java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.m

时间:2016-05-12 13:39:21      阅读:1694      评论:0      收藏:0      [点我收藏+]

标签:

javax.validation.Validator.validator.validate(object, groups) bean验证注解报错,异常:

java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateMessage(ResourceBundleMessageInterpolator.java:187)
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolate(ResourceBundleMessageInterpolator.java:115)
	at org.hibernate.validator.internal.engine.ValidationContext.interpolate(ValidationContext.java:370)
	at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolation(ValidationContext.java:284)
	at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolations(ValidationContext.java:246)
	at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:289)
	at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:133)
	at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
	at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:478)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:158)
	at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:136)
	at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreUpdate(BeanValidationEventListener.java:102)
	at org.hibernate.action.internal.EntityUpdateAction.preUpdate(EntityUpdateAction.java:228)
	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:115)
	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)


源码位置:

	private String interpolateExpression(String message, Pattern pattern, Context context, Locale locale) {
		Matcher matcher = pattern.matcher( message );
		StringBuffer sb = new StringBuffer();

		while ( matcher.find() ) {
			String match = matcher.group( 1 );
			InterpolationTerm expression = new InterpolationTerm( match, locale );
			if ( expression.needsEvaluation() ) {
				String resolvedExpression = expression.interpolate( context );
				resolvedExpression = Matcher.quoteReplacement( resolvedExpression );
				matcher.appendReplacement( sb, resolvedExpression );
			}
		}
		matcher.appendTail( sb );
		return sb.toString();
	}

原因:name值为空,有@Length时,需要@NotNull属性,否则会抛出异常

	//@NotNull(message = "样品名称为空或不存在")
	@Length(min=1, max=200)
	@ExcelField(title="样品名称", align=2, sort=10)
	public String getName() {
		return name;
	}


java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.m

标签:

原文地址:http://blog.csdn.net/cccaaa8888/article/details/51365180

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!