tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TIKA-2908) TikaException: Failed to close temporary resource - how to fix?
Date Thu, 18 Jul 2019 19:17:00 GMT

    [ https://issues.apache.org/jira/browse/TIKA-2908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16888263#comment-16888263

Hudson commented on TIKA-2908:

FAILURE: Integrated in Jenkins build tika-2.x-windows #434 (See [https://builds.apache.org/job/tika-2.x-windows/434/])
Update changes.txt to reflect TIKA-2908. (tallison: rev 806489b59aebe4208cd21ad40fa0cf2c9e0e35e7)
* (edit) CHANGES.txt

> TikaException: Failed to close temporary resource - how to fix?
> ---------------------------------------------------------------
>                 Key: TIKA-2908
>                 URL: https://issues.apache.org/jira/browse/TIKA-2908
>             Project: Tika
>          Issue Type: Bug
>          Components: ocr, parser
>    Affects Versions: 1.21
>            Reporter: Marichi Gupta
>            Assignee: Tim Allison
>            Priority: Blocker
>              Labels: ocr, tesseract, tika
>             Fix For: 1.22
> I am using Apache Tika on Windows 10, jre 1.8.0_181, and I've imported Tika using Maven
with the following dependencies:
> {{<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
<version>3.8.1</version> <scope>test</scope> </dependency> <dependency>
<groupId>org.apache.tika</groupId> <artifactId>tika-parsers</artifactId>
<version>1.21</version> </dependency> </dependencies>}}
> I have the code below for performing OCR using Tesseract (which I have independently
tested and know to be working):
> public static void OCRTest() {
> try { 
> BufferedImage im = ImageIO.read(new File(OCR_IMAGE)); 
> {{TesseractOCRConfig config = new TesseractOCRConfig();}}
> config.setTessdataPath("C:
> Program Files\\Tesseract-OCR\tessdata");
> config.setTesseractPath("C:
> Program Files
> Tesseract-OCR"); 
> {{ParseContext parseContext = new ParseContext();}}
> parseContext.set(TesseractOCRConfig.class, config);
> TesseractOCRParser parser = new TesseractOCRParser();
> BodyContentHandler handler = new BodyContentHandler();
> Metadata metadata = new Metadata();
> try {
> {{parser.parse(im, handler, metadata, parseContext);}}
> System.out.println(handler.toString());
> } catch (SAXException e)\{ e.printStackTrace(); }
> catch (TikaException e) \{ e.printStackTrace(); }
> } catch (IOException e)\{ e.printStackTrace(); }
> }
> I run into the following exception:
> org.apache.tika.exception.TikaException: Failed to close temporary resources at org.apache.tika.io.TemporaryResources.dispose(TemporaryResources.java:174)
at org.apache.tika.parser.ocr.TesseractOCRParser.parse(TesseractOCRParser.java:251) at test.test.App.OCRTest(App.java:46)
at test.test.App.main(App.java:30) Caused by: java.nio.file.FileSystemException: C:\Users\m\AppData\Local\Temp\apache-tika-2643805894084124300.tmp:
The process cannot access the file because it is being used by another process. 
> The tmp file is present in the Temp folder. I have the source code downloaded and have
stepped through it with the debugger - the error comes from attempting to close the tmp file.
There is another post on this board (https://issues.apache.org/jira/browse/TIKA-1732) where
someone else has run into the same exception, although with the AutoDetectParser and not Tesseract.
Their issue seemed to be a conflict in their imported jars, but I run into this issue even
with only the Apache Tika libraries installed. I have a feeling this is a concurrency issue,
but I can't pinpoint the conflict.
> I don't run into this issue when using the Tika's AutoDetectParser, only with the TesseractOCRParser.
This is an important part of an application I'm working on, so I would really appreciate any
insights on how to proceed.

This message was sent by Atlassian JIRA

View raw message