nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
public ModelAndView Details(@ModelAttribute("") @Validated App app, BindingResult result, @RequestParam(value="paramSessionAttr", required=false) String sessionAttr, @RequestParam("paramAction") @NotNull @NotEmpty String param_action){ ... }
当我在 getParam 中实现 @NotNull
@NotEmpty
注释验证器时,它的原因错误是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appController' defined in file [C:\apache-tomcat-8.0.29\wtpwebapps\Application Portal\WEB-INF\classes\com\controller\AppController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.controller.AppController]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems:
The type javax.validation.Payload cannot be resolved. It is indirectly referenced from required .class files
The import javax.validation cannot be resolved
使用 hibernate-validator-5.2.2.jar
Tomcat 8.0
spring-4.2.3.jar
当我导入 javax.validator 时 validation-api-1.1.0.jar [JSR-349]
导致此错误,
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
当我删除 @NotNull
@NotEmpty
和 validation-api-1.1.0.final
时工作正常。
当我在没有 @NotNull
的情况下导入 validation-api-1.1.0.final
时 @NotEmpty
我得到了这个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
我尝试从其他来源下载并导入validation-api-1.1.0.final
我也遇到了与上述相同的错误。
我在 hibernate-validator-5.2.2-Final.jar
中找到了 org.hibernate.validator.internal.engine.ConfigurationImpl
servlet 可能是 bean 配置遗漏了什么?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<context:component-scan base-package="com.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB/INF/messages</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<!--<bean id="validator" class="org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean" /> -->
<mvc:default-servlet-handler/>
<mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
<mvc:annotation-driven />
</beans>
导入库
- hibernate-validator-5.2.2.Final.jar
- hibernate-validator-annotation-processor-5.2.2.Final.jar
- hibernate-validator-cdi-5.2.2.Final.jar
- javax.el-api-3.0.0.jar
- jboss-logging.jar
- spring-context-4.2.3.RELEASE.jar
- spring-beans-4.2.3.RELEASE.jar
- 验证-api-1.1.0.final.jar
- 同学-1.3.1.jar
- slf4j-jdk14-1.7.13.jar
参考文献
- Exception in hibernate-validator. nested exception is java.lang.NoClassDefFoundError: ConfigurationImpl
- Javax Validation
- http://central.maven.org/maven2/org/hibernate/hibernate-validator/5.2.2.Final/hibernate-validator-5.2.2.Final.pom
- http://docs.jboss.org/hibernate/validator/5.2/reference/en-US/pdf/hibernate_validator_reference.pdf
我猜某些库丢失了,因为我下载了库 à la carte
您从 here 下载包而不是下载 à la carte
设置指南
http://hibernate.org/validator/documentation/getting-started/
在您的项目中导入并包含以下库
- 同学-1.1.0.jar
- javax.el-2.2.4.jar
- javax.el-api-2.2.4.jar
- jboss-logging-3.2.1.Final.jar
- validation-api-1.1.0.Final.jar
- hibernate-validator-5.2.2.Final.jar
- hibernate-validator-annotation-processor-5.2.2.Final.jar
- hibernate-validator-cdi-5.2.2.Final.jar
那么您的代码应该可以正常工作了。
可能发生库冲突。
我的情况:
jboss.common:jboss-common:jar:1.2.1.GA
org.jboss.logging:jboss-logging:jar:3.3.0.Final
存在于一起,但他们有相同的包"org.jboss.logging"。
只排除pom.xml
中的一个
我使用 sts 生成了 spring 项目。我收到上述错误。折腾了2天,觉得调整版本解决了问题。
在 pom.xml 的父部分中,我将 1.5.4 替换为 1.2.5
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
我在使用 JSR 303 bean 验证时遇到了同样的问题,我在下面添加了两个 jar(以及 validation-api-1.1.0.final.jar 和 hibernate-validator-5.0.1.final.jar),问题得到解决
1.同学-0.8.0.jar 2.jboss-logging-3.1.0.ga.jar
public ModelAndView Details(@ModelAttribute("") @Validated App app, BindingResult result, @RequestParam(value="paramSessionAttr", required=false) String sessionAttr, @RequestParam("paramAction") @NotNull @NotEmpty String param_action){ ... }
当我在 getParam 中实现 @NotNull
@NotEmpty
注释验证器时,它的原因错误是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appController' defined in file [C:\apache-tomcat-8.0.29\wtpwebapps\Application Portal\WEB-INF\classes\com\controller\AppController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.controller.AppController]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems:
The type javax.validation.Payload cannot be resolved. It is indirectly referenced from required .class files
The import javax.validation cannot be resolved
使用 hibernate-validator-5.2.2.jar
Tomcat 8.0
spring-4.2.3.jar
当我导入 javax.validator 时 validation-api-1.1.0.jar [JSR-349]
导致此错误,
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
当我删除 @NotNull
@NotEmpty
和 validation-api-1.1.0.final
时工作正常。
当我在没有 @NotNull
的情况下导入 validation-api-1.1.0.final
时 @NotEmpty
我得到了这个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
我尝试从其他来源下载并导入validation-api-1.1.0.final
我也遇到了与上述相同的错误。
我在 hibernate-validator-5.2.2-Final.jar
org.hibernate.validator.internal.engine.ConfigurationImpl
servlet 可能是 bean 配置遗漏了什么?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<context:component-scan base-package="com.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB/INF/messages</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<!--<bean id="validator" class="org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean" /> -->
<mvc:default-servlet-handler/>
<mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
<mvc:annotation-driven />
</beans>
导入库
- hibernate-validator-5.2.2.Final.jar
- hibernate-validator-annotation-processor-5.2.2.Final.jar
- hibernate-validator-cdi-5.2.2.Final.jar
- javax.el-api-3.0.0.jar
- jboss-logging.jar
- spring-context-4.2.3.RELEASE.jar
- spring-beans-4.2.3.RELEASE.jar
- 验证-api-1.1.0.final.jar
- 同学-1.3.1.jar
- slf4j-jdk14-1.7.13.jar
参考文献
- Exception in hibernate-validator. nested exception is java.lang.NoClassDefFoundError: ConfigurationImpl
- Javax Validation
- http://central.maven.org/maven2/org/hibernate/hibernate-validator/5.2.2.Final/hibernate-validator-5.2.2.Final.pom
- http://docs.jboss.org/hibernate/validator/5.2/reference/en-US/pdf/hibernate_validator_reference.pdf
我猜某些库丢失了,因为我下载了库 à la carte
您从 here 下载包而不是下载 à la carte
设置指南 http://hibernate.org/validator/documentation/getting-started/
在您的项目中导入并包含以下库
- 同学-1.1.0.jar
- javax.el-2.2.4.jar
- javax.el-api-2.2.4.jar
- jboss-logging-3.2.1.Final.jar
- validation-api-1.1.0.Final.jar
- hibernate-validator-5.2.2.Final.jar
- hibernate-validator-annotation-processor-5.2.2.Final.jar
- hibernate-validator-cdi-5.2.2.Final.jar
那么您的代码应该可以正常工作了。
可能发生库冲突。
我的情况:
jboss.common:jboss-common:jar:1.2.1.GA
org.jboss.logging:jboss-logging:jar:3.3.0.Final
存在于一起,但他们有相同的包"org.jboss.logging"。
只排除pom.xml
中的一个我使用 sts 生成了 spring 项目。我收到上述错误。折腾了2天,觉得调整版本解决了问题。
在 pom.xml 的父部分中,我将 1.5.4 替换为 1.2.5
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
我在使用 JSR 303 bean 验证时遇到了同样的问题,我在下面添加了两个 jar(以及 validation-api-1.1.0.final.jar 和 hibernate-validator-5.0.1.final.jar),问题得到解决
1.同学-0.8.0.jar 2.jboss-logging-3.1.0.ga.jar