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

StackOverflowError loading ffmpeg in Tomcat on Linux #113

Closed
jshailes opened this issue Mar 31, 2015 · 6 comments
Closed

StackOverflowError loading ffmpeg in Tomcat on Linux #113

jshailes opened this issue Mar 31, 2015 · 6 comments
Labels

Comments

@jshailes
Copy link

I'm having some difficulties loading the ffmpeg javacpp libraries in Tomcat on Linux. It works fine in Tomcat on Windows, and also fine in Linux when running as a standalone.

In my application I'm using javacv, flandmark and ffpeg. Both javacv and flankmark work fine but when I instantiate FFmpegFrameRecorder I receive a couple of errors:

Error loading class org/bytedeco/javacpp/Loader.
java.lang.NoClassDefFoundError: Could not initialize class org.bytedeco.javacpp.avcodec
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:340)
    at org.bytedeco.javacpp.Loader.load(Loader.java:385)
    at org.bytedeco.javacpp.Loader.load(Loader.java:353)
    at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1383)
    at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:148)
    at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:125)

I've read on a thread somewhere that this error could be fixed by first making a call to org.bytedeco.javacpp.Loader.load(org.bytedeco.javacpp.avcodec.class);, however this results in the following error:

Error loading class org/bytedeco/javacpp/Loader.
java.lang.StackOverflowError
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:524)
    at org.bytedeco.javacpp.Loader.load(Loader.java:410)
    at org.bytedeco.javacpp.Loader.load(Loader.java:353)
    at org.bytedeco.javacpp.avcodec.<clinit>(avcodec.java:13)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:340)
    at org.bytedeco.javacpp.Loader.load(Loader.java:385)

I've created the simplest maven test project I could to demonstrate these two scenarios - it can be downloaded from http://picosoft.co.uk/ffmpeg-test.zip.

Thanks for your time,

James

@saudet
Copy link
Member

saudet commented Apr 1, 2015

What is the name and version of your Linux distribution? With which version of JavaCV?

@jshailes
Copy link
Author

jshailes commented Apr 1, 2015

I upgraded last night to Xubuntu 15.04 to see if that helped (it didn't), previously I was running Xubuntu 14.04.

JRE is 1.8.0_11-b12, although I'm pretty sure 1.7 yields the same problem - I can confirm this if it helps.

Servlet container is vFabric Tomcat Server 2.9.6 which is based on tomcat 7.

I've tested unsuccessfully with JavaCV 0.8, 0.9, and 0.10.

@saudet
Copy link
Member

saudet commented Apr 1, 2015

There's one thing we need to be careful when using Tomcat with JNI:
http://wiki.apache.org/tomcat/HowTo#I.27m_encountering_classloader_problems_when_using_JNI_under_Tomcat
You're not getting the same error, but it might be related. Make sure to put all JAR files related to JavaCV in the shared folder, or if that doesn't work, try some other way to have them loaded by the system class loader.

@saudet
Copy link
Member

saudet commented Jul 17, 2015

Have you been able to make any progress with this?

@jshailes
Copy link
Author

I've not spent much more time on it to be honest, I just test on windows for anything involving video.

@saudet
Copy link
Member

saudet commented Jan 18, 2018

This is most likely fixed with commit bytedeco/javacpp@7968093 in JavaCPP and JavaCV 1.4.

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

No branches or pull requests

2 participants