I am following google drive v3 api quickstart
tutorial
I don't want to use gradle for this application since is a group project.
I have downloaded the google drive v3 libraries.
I am using Intellij, and I have added all of the jar to the class path. All jars are imported successfully and the IDE doesn't give any error.
At run time I get a warning which from reading online seems to be a problem with Windows Compatibility.
I have downloaded the .json file with user ID and user secret and placed it in the same folder as the main
My code is the same as the one of the quickstart example:
The error i get is the following:
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\HP\.credentials\drive-java-quickstart
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\HP\.credentials\drive-java-quickstart
Exception in thread "main" java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2624)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
at com.google.api.client.util.IOUtils.deserialize(IOUtils.java:171)
at com.google.api.client.util.store.FileDataStoreFactory$FileDataStore.<init>(FileDataStoreFactory.java:102)
at com.google.api.client.util.store.FileDataStoreFactory.createDataStore(FileDataStoreFactory.java:73)
at com.google.api.client.util.store.AbstractDataStoreFactory.getDataStore(AbstractDataStoreFactory.java:55)
at com.google.api.client.auth.oauth2.StoredCredential.getDefaultDataStore(StoredCredential.java:171)
at com.google.api.client.auth.oauth2.AuthorizationCodeFlow$Builder.setDataStoreFactory(AuthorizationCodeFlow.java:736)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.setDataStoreFactory(GoogleAuthorizationCodeFlow.java:209)
at com.elox.Main.authorize(Main.java:77)
at com.elox.Main.getDriveService(Main.java:93)
at com.elox.Main.main(Main.java:103)
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.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
I don't Understand why I get this error or how I could correct it
I know that this is an old post, but I had almost the exact same stacktrace and couldn't find an answer. So, I'm posting in hopes that it will help those that come after me.
The issue appears to be related to file/directory permissions. As soon as I changed the filepath being used by the FileDataStoreFactory to a directory that my application had read/write permissions to, OAuth2 worked correctly. So, make sure that you are using a non-restricted filepath and that all of the directories have the correct ownership and permissions.
Related
I'm working on some legacy code in JAVA.
It's like "pure java" with JSP and servlets, no maven and no spring boot.
I usually use VSCODE but the "way it's always been done" is with ECLIPSE and TOMCAT with some special configurations and a keystore.
My problem is: after I modify a .java file on VSCODE the TOMCAT starts giving up the errors:
ago 28, 2020 11:42:13 AM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
ADVERTÊNCIA: The web application [header] appears to have started a thread named [Abandoned connecti
on cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(Unknown Source)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
ago 28, 2020 11:42:13 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
And I have no idea why or how to fix. I end up having to revert the changes, copy and paste the changes inside Eclipse. And then it works, even GIT says there's no changes...
No idea why, but excluding and then reading any file from buildpath seems to be the trick.
Maybe just touching the ".classpath" file should be enough.
That file doesn't appear in Eclipse by default, but does in VSCODE. Its located in the root folder of the project.
It appears you don't need to keep doing this every time.
I'm using git flow and only as I've changed to a new feature branch I had to do this again.
I'm developing a web app using Spring MVC with Maven and with some functionality using tess4j for the OCR.
My dev environment:
Eclipse Neon.3
os: win server 2008R2
jvm 64 bit
apache tomecat 9
I downloaded the latest version of Tess4J from http://tess4j.sourceforge.net/ and imported it into eclipse. I am following this URL, I followed all the steps but when I try to execute it I am getting the following error:
java.lang.UnsatisfiedLinkError: Le module spécifié est introuvable.
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.Native.open(Native.java:1759)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:412)
at com.sun.jna.Native.loadLibrary(Native.java:391)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:75)
at net.sourceforge.tess4j.TessAPI.<clinit>(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)
I try to some tutorial and i add:
.MV C++ 2015 Redistributable (x64)
.I add on C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\temp\tess4j\win32-x86-64
I still have the error.
What is essentially happening is System is not able to find a native module called 'spécifié' (I think, I can't read French) to load. Now the mechanics is like this. during load time somewhere (probably in the jar) a call is being made like
System.loadLibrary("spécifié");
Which is failing because the native library is not on PATH. So a simple solution would be to put the module on PATH. If it is an Windows environment, then the module would be a DLL file called spécifié.dll. This file must be placed on the path (e.g. set PATH=C:\xyz\spécifié.dll).
Try it and check.
Note: This question was originally titled "How can I reset the path of FFMPEG in Java?" but, as it has been pointed out in the comments and the answer, the issue is not with Java, so I've changed the title to make it easier to find for others with the same issue.
I accidentally set the path for FFMPEG to a different folder, and I can't change it back.
I'm using Processing (the library and its IDE) and the user-created Video Export library to capture and write to an mp4 video file. The library required FFMPEG, so I downloaded and installed it. After I installed it, I ran the code, and the library called Java to request the path of FFMPEG. I wrongly set the path to a different folder (which I eventually deleted), and immediately realized my mistake. I ran the code again to see if I could trigger the prompt again to correct the path.
The console response I received was: (I'm sure most of it doesn't have to do with the actual issue. However, I wanted to show all of it in case it somehow does.)
Oct 24, 2016 10:23:25 PM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.io.IOException: Cannot run program
"C:...\Processing\Octree_Graphics\data\FFMPEG\ff-prompt.bat":
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at
com.hamoid.VideoExport.startFfmpeg(Unknown Source) at
com.hamoid.VideoExport.initialize(Unknown Source) at
com.hamoid.VideoExport.saveFrame(Unknown Source) at
Octree_Graphics.draw(Octree_Graphics.java:90) at
processing.core.PApplet.handleDraw(PApplet.java:2399) at
processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:731)
at
jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
at
jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
at
jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
at
jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at
com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
at
com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.util.TimerThread.mainLoop(Timer.java:555) at
java.util.TimerThread.run(Timer.java:505) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:386) at
java.lang.ProcessImpl.start(ProcessImpl.java:137) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 17 more
VideoExport error: Ffmpeg failed. Study
C:...\Processing\Octree_Graphics\basic.mp4.txt for more details.
I need to find a way to reset the path of FFMPEG that Java has. I have tried uninstalling and reinstalling the library, but I haven't tried Java (I don't want to mess with anything it has in its current state).
Firstly, from what I can tell, this is merely inside the library in Processing, not inside of Java itself.
I have found you can reset the ffmpeg directory by running the
".forgetFfmpegPath();" method on the VideoExport object. You only need to run it once then you can remove it.
Inside the Video Export docs the method has the description "Makes the library forget about where the ffmpeg binary was located."
You can find the documentation of the method in the VideoExport documentation, which can be found in the Processing IDE at "Help -> Libraries Reference -> Video Export". (Note the VideoExport library must be installed)
I understand this is two years old, but I am here for other people who have this issue.
I just had this issue and found this question, but there was no answer, so I am giving the answer I found worked.
I have Spring boot Webserver project which works ok in my PC under Intellij IDEA, but it not works after distributing to the same PC as war file - NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI.
my code:
ITesseract instance = new Tesseract(); // JNA Interface Mapping
instance.setDatapath(new File(datapath).getPath());
instance.setLanguage("eng");
try {
String result = instance.doOCR(imageFile);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
I have only one maven dependency, releted to Tess4J:
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>
I've got the error after running my distributed war:
There was an unexpected error (type=Internal Server Error, status=500).
Could not initialize class net.sourceforge.tess4j.TessAPI
Full Tomcat log:
java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196) ~[tess4j-3.0.0.jar:3.0.0]
at ocr.OCRController.handleFileUpload(OCRController.java:127) ~[classes/:0.3.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
How can I fix the error? I have the plan to host this app in Windows Azure under Tomcat. Thank you for any help, friends!
The problem was in temp folder - it does not contain all necessary dlls.
Info for community:
1. Check temp folder under tomact - for me the path to it is:
D:\Programs_Files\apache-tomcat-8.0.27\temp
This temp folder MUST contain the directory tess4j\win32-x86-64 with next 3 files: gsdll64.dll, liblept171.dll, libtesseract304.dll (or your version)
I had my problem because the directory tess4j\win32-x86-64 have never been created in temp.
BUT
My app works ok under Intellij IDEA because another Temp folder (for IDEA) works ok - C:\Users\Iuliia\AppData\Local\Temp\
contains tess4j\win32-x86-64\gsdll64.dll, tess4j\win32-x86-64\liblept171.dll, tess4j\win32-x86-64\libtesseract304.dll as expected.
Note, that this files are created in process of calling Tesseract in your code. Not early.
HOW I FIX THE PROBLEM with temp under Tomcat
I've added win32-x86-64\gsdll64.dll, win32-x86-64\liblept171.dll, win32-x86-64\libtesseract304.dll to the resources directory in my project.
Look at my project structure:
After deploying to tomcat, the necessary dlls is under classes directory (important!) - it means they are is in the scope.
Now it will be added to
D:\Programs_Files\apache-tomcat-8.0.27\temp\tess4j\win32-x86-64 as expected.
Another fix for the NoClassDefFoundError is e.g. installing the respective Microsoft C++ Runtime (scroll to the bottom and expand Other Tools and Frameworks):
Since the DLLs are built using Visual Studio 2015/2017, please ensure you have Visual C++ 2015 Redistributable or VC++ 2017 Redistributable installed.
Refer to the Tess4J development tutorial for more details.
I upgraded to Windows 10 and all of a sudden tessarct no longer worked for my app.
As per the Tess4J docs, you need to have VC++ 2017 Redistributable installed.
After I installed it on Windows 10, it all worked fine again.
If you've upgraded to Windows 10, and you are having the above problem, and it worked before, then this is likely your issue.
Good Day,
I a working my way through the official JavaFX FXML tutorial (See source code here). However when I compile it using the Netbeans IDE I get the following error:
Can anyone help me with this
I'm running JDK 1.7 and JavaFX 2.0
init: Deleting:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties
deps-jar: Updating property file:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties
compile: Detected JavaFX Ant API version 1.1 Launching task
from C:\Program Files (x86)\Oracle\JavaFX 2.0 SDK\tools\ant-javafx.jar
Signing JAR:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\dist\FXMLExample.jar
to
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\dist\FXMLExample.jar
as nb-jfx
Warning: The signer certificate will expire within six months. Enter
Passphrase for keystore: Enter key password for nb-jfx: Launching
task from C:\Program Files (x86)\Oracle\JavaFX 2.0
SDK\tools\ant-javafx.jar Skip jar copy to itself: FXMLExample.jar
jfx-deployment: jar: run: Jun 19, 2012 9:10:33 PM
javafx.fxml.FXMLLoader logException SEVERE: The following error
occurred at line 48 in file
/C:/Users/riash/Documents/Riaz/Personal/Java/Samples/FXMLExample/build/classes/fxmlexample/fxml_example.fxml[Ljava.lang.StackTraceElement;#1bb3a11
Exception in Application start method
java.lang.reflect.InvocationTargetException 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
com.javafx.main.Main.launchApp(Main.java:453) at
com.javafx.main.Main.main(Main.java:537) Caused by:
java.lang.RuntimeException: Exception in Application start method at
com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown
Source) at com.sun.javafx.application.LauncherImpl.access$000(Unknown
Source) at com.sun.javafx.application.LauncherImpl$1.run(Unknown
Source) at java.lang.Thread.run(Thread.java:722) Caused by:
javafx.fxml.LoadException: javafx.scene.layout.GridPane does not have
a default property.
Upgrading your JavaFX runtime to at least 2.1 will fix your problem.
The sample source you reference is designed for a 2.1 runtime, not a 2.0 runtime.
The reason the new source is incompatible with 2.0 is that 2.1 adds an inherited #DefaultProperty annotation to the Pane class (this annotated behaviour gets inherited by GridPane). Because of this, when you write fxml using 2.1 you can omit certain tags which get defaulted, making the 2.1 fxml less verbose than what is required for 2.0. A full explanation of this is provided by Dustin Marx in his blog.
Upgrade from JavaFx 2.0 to JavaFx 2.2 will fix this problem.