Unable to load library 'libtesseract304'

我的报错信息如下:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract304': Native library (win32-x86-64/libtesseract304.dll) not found in resource path ([file:/E:/OMS_NEW/UpLoadSys/build/classes/, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/JTwain.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/aopalliance-1.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/aspectj-1.6.13.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/aspriseOCR.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/c3p0-0.9.2.1.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/c3p0-oracle-thin-extras-0.9.2.1.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-beanutils-1.9.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-codec-1.9.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-collections-3.2.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-httpclient-2.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-io-1.4.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-lang-2.6.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/commons-logging-1.2.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/dom4j-1.6.1.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/druid-1.0.9.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/ezmorph-1.0.6.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/httpclientX.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/httpcore-4.4.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/httpmime-4.4.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jai-imageio-core-1.3.1.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jedis-2.6.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jid.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jna-4.2.2.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/json-lib-2.2.3-jdk15.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jsoup-1.8.1.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jul-to-slf4j-1.7.19.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/jxl-2.4.3.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/lept4j-1.1.2.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/log4j-1.2.15.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/mchange-commons-java-0.2.3.4.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/myJar.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/mybatis-3.3.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/mybatis-spring-1.2.3.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/ojdbc14-10.2.0.2.0.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/slf4j-api-1.7.19.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/slf4j-nop-1.7.26.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-aop-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-asm-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-beans-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-context-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-context-support-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-core-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-expression-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-jdbc-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-oxm-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-test-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-tx-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-web-3.0.1.RELEASE.jar, file:/E:/OMS_NEW/UpLoadSys/WebContent/WEB-INF/lib/spring-webmvc-3.0.1.RELEASE.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/annotations-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/catalina-ant.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/catalina-ha.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/catalina-storeconfig.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/catalina-tribes.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/catalina.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/ecj-4.4.2.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/el-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/jasper-el.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/jasper.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/jsp-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/ojdbc6.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/servlet-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-coyote.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-dbcp.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-i18n-es.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-i18n-fr.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-i18n-ja.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-jdbc.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-jni.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-util-scan.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-util.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/tomcat-websocket.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/websocket-api.jar, file:/D:/tomcat-8.0.24/tomcat-8.0.24/lib/xalan-2.7.2.jar])
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
	at com.sun.jna.Library$Handler.(Library.java:147)
	at com.sun.jna.Native.loadLibrary(Native.java:502)
	at com.sun.jna.Native.loadLibrary(Native.java:481)
	at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:77)
	at net.sourceforge.tess4j.TessAPI.(TessAPI.java:42)
	at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
	at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
	at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
	at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
	at com.cjhx.datamining.util.CheckCodeUtil.analysisCode(CheckCodeUtil.java:46)
	at com.cjhx.serviceimpl.LoginAndUploadServiceImpl.getCode(LoginAndUploadServiceImpl.java:380)
	at com.cjhx.serviceimpl.CodeProcess.main(CodeProcess.java:343)

这个错,是本人在做tess4j验证码解析时报错,网上也找了相关资料,没有获得答案,如下是我和同事摸索的排查过程;

PS:注意这个 只是本人排查的过程,并不适用于所有,也不保证正确性。

一、需要检查如下几个地方是否有这个问题,包含libtesseract304.dll(文件地址);并将文件放入对应位置。

1、C:\Windows\SysWOW64 (64位系统)、C:\Windows\System32(32位系统)

2、jdk的bin目录,新建报错的文件夹,例如win32-x86-64,放入文件;我是:E:\TTM\Java\jdk1.8.0_161\bin\win32-x86-64

3、项目的代码目录,网上也有说 项目的bin目录,我是放tess4j的解析同级目录下的;

Unable to load library 'libtesseract304'_第1张图片

二、使用应用服务器(Tomcat )来调用 验证码解析入口功能;

http://127.0.0.1:8081/UpLoadSys/loginandpload/upAll.do?type=12&date=20171212&name=test

你可能感兴趣的:(随笔)