Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeUtil crating tempfile throws exception #8

Open
DImuthuUpe opened this issue Oct 10, 2014 · 4 comments
Open

NativeUtil crating tempfile throws exception #8

DImuthuUpe opened this issue Oct 10, 2014 · 4 comments
Assignees

Comments

@DImuthuUpe
Copy link
Owner

Problem is with File temp = File.createTempFile(parts[0], "." + parts[1]); Where path[0] = /some directory path/filename. If path[0] = filename, this exception doesn't appear.
MacOS 10.9.2
Java 1.7.0_21

java.io.IOException: No such file or directory
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createTempFile(File.java:1879)
        at java.io.File.createTempFile(File.java:1923)
        at com.apache.pdfbox.ocr.tesseract.NativeUtil.loadLibraryResource(NativeUtil.java:22)
        at com.apache.pdfbox.ocr.tesseract.TessBaseAPI.<clinit>(TessBaseAPI.java:50)
        at com.apache.pdfbox.ocr.tesseract.TessBaseAPITest.testBufferedImage(TessBaseAPITest.java:53)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
        at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
        at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
@DImuthuUpe
Copy link
Owner Author

Can't we simply use File temp = File.createTempFile("temp", "." + parts[1]); ?

@jahewson
Copy link
Collaborator

I'm not sure I understand what inputs are triggering this exception? What exactly is the problematic path?

@DImuthuUpe
Copy link
Owner Author

This gives exception
File temp = File.createTempFile("/META-INF/lib/tessbaseapi-macosx-x86_64", "." + parts[1]);

This works fine
File temp = File.createTempFile("tessbaseapi-macosx-x86_64", "." + parts[1]);

I guess problem is with creating temporary folders and this may be a JVM a specific issue.

@jahewson
Copy link
Collaborator

Ok, I see, it's expecting a filename but we've given a path. It would be nice to keep "tessbaseapi" somewhere in the temp file name, so instead of parts[0] I think we could use:

String prefix = new File(parts[0]).getName()
File temp = File.createTempFile(prefix, "." + parts[1]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants