首页 > 解决方案 > java.lang.ClassNotFoundException: javax.validation.Validator

问题描述

我正在尝试在我的遗留项目中添加validation-api2.0.1.jar,该项目依赖于我添加的jar。不使用 maven 或 gradle 来管理它。我通过自动装配使用 javax.validation.Validator 时收到此错误跟踪。

SEVERE: Servlet [controller] in web application [/safehand-web] threw load() exception
java.lang.ClassNotFoundException: javax.validation.Validator
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:713)
    at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:655)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:418)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:397)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:333)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    at 

    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
        at javax.servlet.GenericServlet.init(GenericServlet.java:158)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:989)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4931)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5241)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

这是我正在使用的 jar 列表,

D:\safehand_latest\safehand\web\common-libraries\annotations-api.jar
D:\safehand_latest\safehand\web\common-libraries\antcontrib.jar
D:\safehand_latest\safehand\web\common-libraries\antlr-2.7.7.jar
D:\safehand_latest\safehand\web\common-libraries\ant-web-tasks-1.0.jar
D:\safehand_latest\safehand\web\common-libraries\aopalliance-1.0.jar
D:\safehand_latest\safehand\web\common-libraries\apache-commons-lang.jar
D:\safehand_latest\safehand\web\common-libraries\asm-3.1.jar
D:\safehand_latest\safehand\web\common-libraries\aspectjrt.jar
D:\safehand_latest\safehand\web\common-libraries\aspectjweaver.jar
D:\safehand_latest\safehand\web\common-libraries\avalon-framework-4.2.0.jar
D:\safehand_latest\safehand\web\common-libraries\barcode4j-fop-ext-complete.jar
D:\safehand_latest\safehand\web\common-libraries\batik-all-1.7.jar
D:\safehand_latest\safehand\web\common-libraries\bsh-core-2.0b4.jar
D:\safehand_latest\safehand\web\common-libraries\byte-buddy-1.8.12.jar
D:\safehand_latest\safehand\web\common-libraries\cglib-nodep-2.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\classmate-1.3.4.jar
D:\safehand_latest\safehand\web\common-libraries\cloning-1.7.4.jar
D:\safehand_latest\safehand\web\common-libraries\com.sun.jersey.jersey-core-1.4.0.jar
D:\safehand_latest\safehand\web\common-libraries\commons-beanutils-1.8.3.jar
D:\safehand_latest\safehand\web\common-libraries\commons-cli-1.1.jar
D:\safehand_latest\safehand\web\common-libraries\commons-codec-1.8.jar
D:\safehand_latest\safehand\web\common-libraries\commons-collections-3.1.jar
D:\safehand_latest\safehand\web\common-libraries\commons-dbcp-1.4.jar
D:\safehand_latest\safehand\web\common-libraries\commons-digester-1.8.1.jar
D:\safehand_latest\safehand\web\common-libraries\commons-fileupload-1.3.1.jar
D:\safehand_latest\safehand\web\common-libraries\commons-io-2.4.jar
D:\safehand_latest\safehand\web\common-libraries\commons-lang3-3.1.jar
D:\safehand_latest\safehand\web\common-libraries\commons-logging-1.2.jar
D:\safehand_latest\safehand\web\common-libraries\commons-pool-1.4.jar
D:\safehand_latest\safehand\web\common-libraries\dom4j-1.6.1.jar
D:\safehand_latest\safehand\web\common-libraries\dynamicreports-core-4.0.0.jar
D:\safehand_latest\safehand\web\common-libraries\ecj-4.4.2.jar
D:\safehand_latest\safehand\web\common-libraries\ehcache-3.3.1.jar
D:\safehand_latest\safehand\web\common-libraries\el-api.jar
D:\safehand_latest\safehand\web\common-libraries\elasticsearch-6.1.4.jar
D:\safehand_latest\safehand\web\common-libraries\elasticsearch-rest-client-6.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\elasticsearch-rest-high-level-client-6.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\fop.jar
D:\safehand_latest\safehand\web\common-libraries\freemarker.jar
D:\safehand_latest\safehand\web\common-libraries\genson-1.3.jar
D:\safehand_latest\safehand\web\common-libraries\gnu-crypto.jar
D:\safehand_latest\safehand\web\common-libraries\groovy-all-2.0.1.jar
D:\safehand_latest\safehand\web\common-libraries\gson-2.2.4.jar
D:\safehand_latest\safehand\web\common-libraries\hamcrest-core-1.3.jar
D:\safehand_latest\safehand\web\common-libraries\hamcrest-library-1.3.jar
D:\safehand_latest\safehand\web\common-libraries\hamcrest-unit-test-1.3.jar
D:\safehand_latest\safehand\web\common-libraries\hibernate-commons-annotations-5.0.4.Final.jar
D:\safehand_latest\safehand\web\common-libraries\hibernate-core-5.3.2.Final.jar
D:\safehand_latest\safehand\web\common-libraries\hppc-0.7.3.jar
D:\safehand_latest\safehand\web\common-libraries\htmlcompressor-1.5.3.jar
D:\safehand_latest\safehand\web\common-libraries\httpasyncclient-4.1.3.jar
D:\safehand_latest\safehand\web\common-libraries\httpclient-4.5.5.jar
D:\safehand_latest\safehand\web\common-libraries\httpcore-4.4.9.jar
D:\safehand_latest\safehand\web\common-libraries\httpcore-nio-4.4.9.jar
D:\safehand_latest\safehand\web\common-libraries\httpmime-4.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\iText-2.1.7.jar
D:\safehand_latest\safehand\web\common-libraries\itextpdf-5.5.4.jar
D:\safehand_latest\safehand\web\common-libraries\itext-pdfa-5.5.4.jar
D:\safehand_latest\safehand\web\common-libraries\itext-xtra-5.5.4.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-annotations-2.7.0.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-core-2.7.5.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-core-asl-1.9.2.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-databind-2.7.5.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-datatype-hibernate4-2.4.1.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-jaxrs-1.9.2.jar
D:\safehand_latest\safehand\web\common-libraries\jackson-mapper-asl-1.9.2.jar
D:\safehand_latest\safehand\web\common-libraries\jandex-2.0.5.Final.jar
D:\safehand_latest\safehand\web\common-libraries\jasperreports-6.0.0.jar
D:\safehand_latest\safehand\web\common-libraries\java-json.jar
D:\safehand_latest\safehand\web\common-libraries\javassist-3.22.0-GA.jar
D:\safehand_latest\safehand\web\common-libraries\javax.activation-api-1.2.0.jar
D:\safehand_latest\safehand\web\common-libraries\javax.persistence-api-2.2.jar
D:\safehand_latest\safehand\web\common-libraries\jaxb-api.jar
D:\safehand_latest\safehand\web\common-libraries\jaxb-core.jar
D:\safehand_latest\safehand\web\common-libraries\jaxb-impl.jar
D:\safehand_latest\safehand\web\common-libraries\jboss-logging-3.3.2.Final.jar
D:\safehand_latest\safehand\web\common-libraries\jboss-transaction-api_1.2_spec-1.1.1.Final.jar
D:\safehand_latest\safehand\web\common-libraries\jdom-1.0.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-apache-client-1.6.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-bundle-1.5.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-client.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-core-1.10.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-json-1.19.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-server-1.10.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-servlet-1.10.jar
D:\safehand_latest\safehand\web\common-libraries\jersey-spring-1.1.5.jar
D:\safehand_latest\safehand\web\common-libraries\jmimemagic-0.1.0.jar
D:\safehand_latest\safehand\web\common-libraries\jmock-2.6.0.jar
D:\safehand_latest\safehand\web\common-libraries\jmock-junit3-2.6.0.jar
D:\safehand_latest\safehand\web\common-libraries\jmock-junit4-2.6.0.jar
D:\safehand_latest\safehand\web\common-libraries\jmock-legacy-2.6.0.jar
D:\safehand_latest\safehand\web\common-libraries\jmock-script-2.6.0.jar
D:\safehand_latest\safehand\web\common-libraries\joda-time-2.5.jar
D:\safehand_latest\safehand\web\common-libraries\json-simple-1.1.jar
D:\safehand_latest\safehand\web\common-libraries\jsp-api.jar
D:\safehand_latest\safehand\web\common-libraries\jsr311-api-1.0.jar
D:\safehand_latest\safehand\web\common-libraries\jstl.jar
D:\safehand_latest\safehand\web\common-libraries\jstl-1.2.jar
D:\safehand_latest\safehand\web\common-libraries\jta-1.1.jar
D:\safehand_latest\safehand\web\common-libraries\jtidy-r938.jar
D:\safehand_latest\safehand\web\common-libraries\junit-4.11.jar
D:\safehand_latest\safehand\web\common-libraries\log4j-1.2.17.jar
D:\safehand_latest\safehand\web\common-libraries\log4j-api-2.3.jar
D:\safehand_latest\safehand\web\common-libraries\log4j-core-2.3.jar
D:\safehand_latest\safehand\web\common-libraries\log4j-iostreams-2.3.jar
D:\safehand_latest\safehand\web\common-libraries\log4j-web-2.3.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-analyzers-common-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-core-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-highlighter-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-join-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-memory-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-queries-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-queryparser-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\lucene-sandbox-7.2.1.jar
D:\safehand_latest\safehand\web\common-libraries\mail-1.4.jar
D:\safehand_latest\safehand\web\common-libraries\mssql-jdbc-6.2.2.jre8.jar
D:\safehand_latest\safehand\web\common-libraries\mysql-connector-java-5.1.6-bin.jar
D:\safehand_latest\safehand\web\common-libraries\objenesis-1.0.jar
D:\safehand_latest\safehand\web\common-libraries\opencsv-2.3.jar
D:\safehand_latest\safehand\web\common-libraries\org.eclipse.paho.client.mqttv3-1.1.0.jar
D:\safehand_latest\safehand\web\common-libraries\org.json.jar
D:\safehand_latest\safehand\web\common-libraries\pdfbox-app-1.8.4.jar
D:\safehand_latest\safehand\web\common-libraries\poi-3.9.jar
D:\safehand_latest\safehand\web\common-libraries\poi-ooxml-3.8-20120326.jar
D:\safehand_latest\safehand\web\common-libraries\poi-ooxml-schemas-3.8-20120326.jar
D:\safehand_latest\safehand\web\common-libraries\quartz-2.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\quartz-jobs-2.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\quick-json-1.0.2.3.jar
D:\safehand_latest\safehand\web\common-libraries\serializer-2.7.1.jar
D:\safehand_latest\safehand\web\common-libraries\servlet-api.jar
D:\safehand_latest\safehand\web\common-libraries\slf4j-api-1.7.7.jar
D:\safehand_latest\safehand\web\common-libraries\slf4j-log4j12-1.7.7.jar
D:\safehand_latest\safehand\web\common-libraries\smslib-3.5.4.jar
D:\safehand_latest\safehand\web\common-libraries\spring-aop-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-aspects-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-beans-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-context-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-context-support-4.1.7.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-core-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-data-redis-1.0.1.jar
D:\safehand_latest\safehand\web\common-libraries\spring-expression-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-instrument-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-instrument-tomcat-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-jdbc-4.2.2.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-orm-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-oxm-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-config-4.0.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-core-4.0.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-core-tiger-2.0.8.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-crypto-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-javaconfig-1.0.0.CI-20130808.110017-278.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-taglibs-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-security-web-4.1.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-session-1.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-test-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-tx-4.2.2.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-web-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-webmvc-4.3.1.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-webmvc-portlet-3.2.4.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-ws-core-2.2.0.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\spring-xml-2.0.3.RELEASE.jar
D:\safehand_latest\safehand\web\common-libraries\sqljdbc4.jar
D:\safehand_latest\safehand\web\common-libraries\sqljdbc41.jar
D:\safehand_latest\safehand\web\common-libraries\standard.jar
D:\safehand_latest\safehand\web\common-libraries\stripe-java-3.9.0.jar
D:\safehand_latest\safehand\web\common-libraries\super-csv-2.0.0-sources.jar
D:\safehand_latest\safehand\web\common-libraries\UserAgentUtils-1.14.jar
D:\safehand_latest\safehand\web\common-libraries\xml-apis-1.3.04.jar
D:\safehand_latest\safehand\web\common-libraries\xmlbeans-2.3.0.jar
D:\safehand_latest\safehand\web\common-libraries\xmlgraphics-commons-1.5.jar
D:\safehand_latest\safehand\web\common-libraries\yuicompressor-2.4.2.jar
D:\safehand_latest\safehand\web\common-libraries\ziputils-1.1.jar
D:\safehand_latest\safehand\web\common-libraries\zxing-2.1.jar
D:\safehand_latest\safehand\web\common-libraries\zxing-j2se-1.7.jar
D:\documents\Jars\all validation jar\validation-api-2.0.1.Final.jar

我不知道出了什么问题以及为什么我不能使用我的 validation-api-2.0.1.Final.jar。有什么帮助或建议吗?

标签: javaspring-mvcjar

解决方案


它准确地说明了您的问题。“java.lang.ClassNotFoundException: javax.validation.Validator” 它无法加载库,因为任何原因。尝试阅读库或尝试找到另一个下载。


推荐阅读