Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java tess4j NoSuchFieldError:Glassfish上带有Primefaces的资源_前缀,但不带JUnit_Java_Maven_Primefaces_Tesseract_Tess4j - Fatal编程技术网

Java tess4j NoSuchFieldError:Glassfish上带有Primefaces的资源_前缀,但不带JUnit

Java tess4j NoSuchFieldError:Glassfish上带有Primefaces的资源_前缀,但不带JUnit,java,maven,primefaces,tesseract,tess4j,Java,Maven,Primefaces,Tesseract,Tess4j,我正在尝试使用tess4j在PDF上进行OCR,当我使用JUnit测试“读取”PDF时,它工作得非常好,但当我使用Primefaces FileUpload运行它时,它就不工作了 监听器调用OCR类,该类的操作与JUnit测试完全相同,只是返回OCR结果的字符串。这是java类: import java.io.File; import net.sourceforge.tess4j.Tesseract; public class PDFToText { public String d

我正在尝试使用tess4j在PDF上进行OCR,当我使用JUnit测试“读取”PDF时,它工作得非常好,但当我使用Primefaces FileUpload运行它时,它就不工作了

监听器调用OCR类,该类的操作与JUnit测试完全相同,只是返回OCR结果的字符串。这是java类:

import java.io.File;

import net.sourceforge.tess4j.Tesseract;

public class PDFToText
{

    public String doOCR(){
            try
            {
                Tesseract tess = new Tesseract();
                String text = "";

                imagePath = new File("D:/path/to/my.pdf");


                tess.setDatapath("D:/path/to/my/tessdata");
                text = tess.doOCR(imagePath);
                System.out.println(text);

                return text;
            } catch (Exception e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }
}
我在这里读了所有这些解决方案,关于JNA版本与com.sun.JNA 3.0.9冲突等

但是我正在使用的tess4j的never版本(3.4.0)甚至不再包括com.sun.java 3.9.0,它使用net.java.dev 4.1.0,这是基于maven存储库中的用法以及jar中的源代码,看起来它具有RESOURCE_PREFIX属性

也做了@S.Isurika在这里说的,但没有帮助: ,无论如何,我不想在任何目录中放置一些JAR,因为我正在使用maven(maven for eclipse)

我还在我的项目中使用Selenium,它的maven配置依赖于net.java.dev.jna版本3.4.0,但这看起来不是问题,因为它在平台文件中也不缺少资源前缀

首先,这对我来说似乎是一个缓存问题,但在我清理了项目、清理了maven、重建了maven的索引、删除了我的.m2文件夹、删除了GL上的部署、重新启动了eclipse甚至机器之后,我迷失了方向

谢谢你的帮助

环境:

  • tess4j 3.4.0(使用net.java.dev.jna 4.1.0。)
  • jai imageio核心1.3.1
  • java 1.8
  • maven编译器插件2.3.2
  • maven war插件2.3
  • 玻璃鱼4.0
  • 素数面6
  • 视窗7
  • myEclipse 2017
这是我的stacktrace:

Exception message:  
/templates/pages/secured/menu/page.xhtml @121,31 fileUploadListener="#{myBean.handleFiles}": java.lang.NoSuchFieldError: RESOURCE_PREFIX

Exception String:   
javax.faces.FacesException: 

/templates/pages/secured/menu/page.xhtml @121,31 fileUploadListener="#{myBean.handleAttachmentFiles}": java.lang.NoSuchFieldError: RESOURCE_PREFIX

Exception Cause:    
javax.el.ELException: /templates/pages/secured/menu/page.xhtml @121,31 fileUploadListener="#{mybean.handleAttachmentFiles}": java.lang.NoSuchFieldError: RESOURCE_PREFIX
Exception Class name:   

javax.faces.FacesException

Stack trace:    

javax.faces.FacesException: /templates/pages/secured/menu/page.xhtml @121,31 
fileUploadListener="#{mybean.handleAttachmentFiles}": java.lang.NoSuchFieldError: RESOURCE_PREFIX 
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:86) 
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) 
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) 
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) 
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AmeractIOStrategy.fireIOEvent(AmeractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AmeractThreadPool$Worker.doWork(AmeractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AmeractThreadPool$Worker.run(AmeractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745) Caused by: javax.el.ELException: /templates/pages/secured/menu/page.xhtml @121,31 fileUploadListener="#{mybean.handleAttachmentFiles}": java.lang.NoSuchFieldError: RESOURCE_PREFIX
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at org.primefaces.component.fileupload.FileUpload.broadcast(FileUpload.java:319)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:755)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) ... 30 more Caused by: java.lang.NoSuchFieldError: RESOURCE_PREFIX
at net.sourceforge.tess4j.util.LoadLibs.<clinit>(LoadLibs.java:63)
at net.sourceforge.tess4j.util.PdfUtilities.<clinit>(PdfUtilities.java:214)
at net.sourceforge.tess4j.util.ImageIOHelper.getIIOImageList(ImageIOHelper.java:392)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
at com.me.utils.file.OCR.PDFToText.doOCR(PDFToText.java:121)
at com.me.proj.webLayer.requestScoped.mybean.handleAttachmentFiles(mybean.java:380)
at com.me.proj.webLayer.requestScoped.mybean$Proxy$_$$_WeldClientProxy.handleAttachmentFiles(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.parser.AstValue.invoke(AstValue.java:275)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) ... 34 more
异常消息:
/templates/pages/secured/menu/page.xhtml@121,31 fileUploadListener=“#{myBean.handleFiles}”:java.lang.NoSuchFieldError:RESOURCE_前缀
异常字符串:
javax.faces.FacesException:
/templates/pages/secured/menu/page.xhtml@121,31 fileUploadListener=“#{myBean.handleAttachmentFiles}”:java.lang.NoSuchFieldError:RESOURCE_前缀
异常原因:
javax.el.ELException:/templates/pages/secured/menu/page.xhtml@121,31 fileUploadListener=“#{mybean.handleAttachmentFiles}”:java.lang.NoSuchFieldError:RESOURCE\u前缀
异常类名称:
javax.faces.FacesException
堆栈跟踪:
javax.faces.FacesException:/templates/pages/secured/menu/page.xhtml@121,31
fileUploadListener=“#{mybean.handleAttachmentFiles}”:java.lang.NoSuchFieldError:RESOURCE\u前缀
在com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:86)
位于com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
在com.sun.faces.lifecycle.LifecycleImpl.execute上(LifecycleImpl.java:198)
位于javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
位于org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
位于org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
位于org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
位于org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
位于org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
位于com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
位于org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
位于org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
位于org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
位于com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
位于org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
位于org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
位于org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
位于org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
位于org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)上
在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
位于org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
位于org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
位于org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
在org.glassfish.grizzly.strategies.ameractostrategy.fireIOEvent(ameractostrategy.java:113)
位于org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
位于org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
位于org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
位于org.glassfish.grizzly.threadpool.AmeractThreadPool$Worker.doWork(AmeractThreadPool.java:564)
位于org.glassfish.grizzly.threadpool.AmeractThreadPool$Worker.run(AmeractThreadPool.java:544)
在java.lang.Thread.run(Thread.java:745)处,由以下原因引起:javax.el.ELException:/templates/pages/secured/menu/page.xhtml@121,31 fileUploadListener=“#{mybean.handleAttachmentFiles}”:java.lang.NoSuchFieldError:RESOURCE\u前缀
位于com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
位于org.primefaces.component.fileupload.fileupload.broadcast(fileupload.java:319)
位于javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:755)
位于javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
在com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)。。。30多个原因:java.lang.NoSuchFieldError:RESOURCE\u前缀
位于net.sourceforge.tess4j.util.LoadLibs。(LoadLibs.java:63)
位于net.sourceforge.tess4j.util.PdfUtilities.(PdfUtilities.j