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

ClassNotFoundException org.bytedeco.javacpp.avutil$AVFrame #137

Closed
noncom opened this issue Apr 28, 2015 · 15 comments
Closed

ClassNotFoundException org.bytedeco.javacpp.avutil$AVFrame #137

noncom opened this issue Apr 28, 2015 · 15 comments

Comments

@noncom
Copy link

noncom commented Apr 28, 2015

I have a project that uses JavaCV, written in Clojure. It loads and works fine in Eclipse. However, in IntelliJ IDEA I get a problem with creating a new FFMpegFrameGrabber. It won't be that sad if the same problem wasn't preventing me from using the program on a different PC, where I distribute it in the form of a JAR (the JAR works fine on my PC ok for some reason, my wild guess is of having the local Maven repo with the dependencies available here).

I have read about the similar issues where it is recommended to manually add the opencv*.jar and ffmpeg*.jar to the classpath, but they are there! So, the deps are present, the project compiles and runs fine in Eclipse and on my home PC. However, on another PC or in IntelliJ IDEA it fails to create the FFMpegFrameGrabber class because it cannot find the imported classes... this is very strange :/ The avutil is some magical device involving native things, so maybe the problem is in this...

Here is the full stack trace:

java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil$AVFrame
 at java.net.URLClassLoader$1.run (URLClassLoader.java:366)
    java.net.URLClassLoader$1.run (URLClassLoader.java:355)
    java.security.AccessController.doPrivileged (AccessController.java:-2)
    java.net.URLClassLoader.findClass (URLClassLoader.java:354)
    java.lang.ClassLoader.loadClass (ClassLoader.java:425)
    sun.misc.Launcher$AppClassLoader.loadClass (Launcher.java:308)
    java.lang.ClassLoader.loadClass (ClassLoader.java:358)
    nest.java.JavaCVPlayer.loadFile (JavaCVPlayer.java:89)
    sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke (Method.java:606)
    clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)
    clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
    user$eval1642.invoke (form-init7720092785525042840.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6703)
    clojure.lang.Compiler.eval (Compiler.java:6666)
    clojure.core$eval.invoke (core.clj:2927)
    clojure.main$repl$read_eval_print__6625$fn__6628.invoke (main.clj:239)
    clojure.main$repl$read_eval_print__6625.invoke (main.clj:239)
    clojure.main$repl$fn__6634.invoke (main.clj:257)
    clojure.main$repl.doInvoke (main.clj:257)
    clojure.lang.RestFn.invoke (RestFn.java:1523)
    clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__870.invoke (interruptible_eval.clj:67)
    clojure.lang.AFn.applyToHelper (AFn.java:152)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invoke (core.clj:624)
    clojure.core$with_bindings_STAR_.doInvoke (core.clj:1862)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:51)
    clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__912$fn__915.invoke (interruptible_eval.clj:183)
    clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__905.invoke (interruptible_eval.clj:152)
    clojure.lang.AFn.run (AFn.java:22)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
    java.lang.Thread.run (Thread.java:745)
@saudet
Copy link
Member

saudet commented Apr 29, 2015

That usually means it's having problems loading the native library files. Could you also check the cause of the exception? It usually makes it clear what the original error is. Thanks!

@noncom
Copy link
Author

noncom commented Apr 29, 2015

Yeah, certainly looks like the natives trouble (btw, the os is Windows 7 and Windows 8, both 64 bit). The cause of the exception, unfortunately, does not tell much more. There is only one cause (calling getCause() on it returnes null), and it is not much different than the original message:

java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil$AVFrame
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at nest.java.JavaCVPlayer.loadFile(JavaCVPlayer.java:89)
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:606)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at user$eval1642.invoke(form-init7720092785525042840.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6666)
at clojure.core$eval.invoke(core.clj:2927)
at clojure.main$repl$read_eval_print__6625$fn__6628.invoke(main.clj:239)
at clojure.main$repl$read_eval_print__6625.invoke(main.clj:239)
at clojure.main$repl$fn__6634.invoke(main.clj:257)
at clojure.main$repl.doInvoke(main.clj:257)
at clojure.lang.RestFn.invoke(RestFn.java:1523)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__870.invoke(interruptible_eval.clj:67)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:624)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:51)
at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__912$fn__915.invoke(interruptible_eval.clj:183)
at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__905.invoke(interruptible_eval.clj:152)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Is there any special, not very traditional mechanism that is used to load the native libraries?

@saudet
Copy link
Member

saudet commented Apr 29, 2015

The JNI wrappers are built with MSVC10, so that might require the appropriate runtime libraries installed on the machine. They are included in the JARs for OpenCV, but for FFmpeg, I'm thinking we should be able to get away with MinGW, so I think I'll try to change that...

@noncom
Copy link
Author

noncom commented Apr 29, 2015

Quite possible! This evening I'll have a chance to test the case on one more Windows machine.. However, what's also bugging me is that the setup does not work on the same machine, if I open the project with IntelliJ/Cursive (Clojure IDE), rather than with Eclipse. I can't even imagine, what can be so different about their classloaders. Also, meanwhile I am trying to contact the Cursive team with this same very issue and ask them about any pecularities in classloading... I hope we'll manage to nail this one bug down :) JavaCV is a very smooth experience and I really like it improving and persisting in this respect.

@noncom
Copy link
Author

noncom commented Apr 30, 2015

@saudet Hello! How is it going? Any news or thoughts on this one? I haven't been able to test more yet, but it is one of my highest priorities. No news from Cursive either..

@noncom
Copy link
Author

noncom commented May 1, 2015

I have setup a test project: https://github.com/noncom/cursive-jme-jcv and contacted Colin, the creator of Cursive, now we are looking into the subject.

saudet added a commit to bytedeco/javacpp-presets that referenced this issue May 2, 2015
…pported GCC compiler for FFmpeg, FFTW, and GSL under Windows as well, to prevent compatibility issues (issue bytedeco/javacv#137)
@saudet
Copy link
Member

saudet commented May 2, 2015

I've just updated the presets so that FFmpeg now gets built with MinGW's GCC (bytedeco/javacpp-presets@52df5ad), and it seems to work fine here. It should fix whatever issue you had too. Let me know though, thanks!

@noncom
Copy link
Author

noncom commented May 2, 2015

@saudet great! is it only available in the source form, or is the Maven artifact is up to date already?

@saudet
Copy link
Member

saudet commented May 2, 2015

@noncom
Copy link
Author

noncom commented May 5, 2015

@saudet Thank you for the binaries! Still testing in progress. I have no access to more computers right now to check if it works on the other computer that it failed the last time (it will be available after about 10-20 days from now). Also, I am trying to check it on the sample project in Cursive (IntelliJ IDEA), and it fails to find the sonatype snapshots repo, so I cannot get to the actual testing %).. However, Eclipse finds the repo, gets the dep and works just fine with the project (as it did before, also). So, waiting for: 1) the opportunity to check on a suspect machine, 2) what Cursive team says about all this...

@noncom
Copy link
Author

noncom commented May 25, 2015

@saudet well, here is the situation update:

  1. IntelliJ IDEA + Cursive cannot fetch the new version of the binary that you have provided. It fails with the following error:
Leiningen aborted: exit code 1

Could not find artifact org.bytedeco.javacpp-presets:ffmpeg:jar:windows-x86:2.6.1-1.0-SNAPSHOT in clojars (https://clojars.org/repo/)
Could not find artifact org.bytedeco.javacpp-presets:ffmpeg:jar:windows-x86:2.6.1-1.0-SNAPSHOT in jme3 (http://updates.jmonkeyengine.org/maven/)
Could not find artifact org.bytedeco.javacpp-presets:ffmpeg:jar:windows-x86:2.6.1-1.0-SNAPSHOT in sonatype (https://oss.sonatype.org/content/repositories/snapshots/)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

What is interesting, Eclipse + CCW finds the library OK! So, within Eclipse (my usual setup for work) I have built the app and run it on the same Windows machine that it was failing before (the machine became accessible for me again).

  1. On the machine, where the build was failing, it still fails :(... The situation is the same. Looks like the error is not in the MSVC libraries? Maybe you could tell me which exactly version of the redistributable is required, and I'll try to install it on the machine and see if the problem will be gone? How do you think, will it fix? Or maybe can you think of another way to find the cause of the error? Maybe enable some deep-level logging or something... ?

@saudet
Copy link
Member

saudet commented May 27, 2015

You could try unzipping all the DLLs, and running Dependency Walker on them to make sure the system finds all their dependencies. That should help us pinpoint the cause.

@saudet
Copy link
Member

saudet commented Jul 17, 2015

This should all be fixed with version 1.0. Could you give it a try and let me know if you encounter any errors? Thanks!

@saudet
Copy link
Member

saudet commented Oct 12, 2015

Given the lack of feedback, I'm assuming this issue has been fixed and everything is working fine with JavaCV 1.0. Let me know if this isn't the case though, thank you!

@saudet saudet closed this as completed Oct 12, 2015
@neat-soft
Copy link

Hi @saudet
Please help me.
I`ve got same problem.

It works fine with debug mode, but when I release apk and install it on my phone, it crashes with FFmpegFrameRecorder

Please check my log cat

                                                             Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
                                                                at java.lang.Class.classForName(Native Method)
                                                                at java.lang.Class.forName(Class.java:204)
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:413)
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:381) 
                                                                at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650) 
                                                                at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:59) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:24) 
                                                                at android.os.AsyncTask$2.call(AsyncTask.java:287) 
                                                                at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
                                                                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                                                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                                                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                                                                at java.lang.Thread.run(Thread.java:841) 
                                                             Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacpp/avutil
                                                                at java.lang.Class.classForName(Native Method) 
                                                                at java.lang.Class.forName(Class.java:204) 
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:413) 
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:381) 
                                                                at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650) 
                                                                at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:59) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:24) 
                                                                at android.os.AsyncTask$2.call(AsyncTask.java:287) 
                                                                at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
                                                                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                                                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                                                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                                                                at java.lang.Thread.run(Thread.java:841) 
                                                             Caused by: java.lang.ClassNotFoundException: Didn't find class "org.bytedeco.javacpp.avutil" on path: /data/app/com.unrapp.app-1.apk
                                                                at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
                                                                at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
                                                                at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
                                                                at java.lang.Class.classForName(Native Method) 
                                                                at java.lang.Class.forName(Class.java:204) 
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:413) 
                                                                at org.bytedeco.javacpp.Loader.load(Loader.java:381) 
                                                                at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650) 
                                                                at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:59) 
                                                                at com.unrapp.app.Controllers.CreateSplashVideoTask.doInBackground(CreateSplashVideoTask.java:24) 
                                                                at android.os.AsyncTask$2.call(AsyncTask.java:287) 
                                                                at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
                                                                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                                                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                                                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                                                                at java.lang.Thread.run(Thread.java:841) 

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

No branches or pull requests

3 participants