frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

Resolved exception caused by Handler execution: org.springframework.web.util.NestedServletException (...) #191

Closed PulsarFox closed 6 years ago

PulsarFox commented 6 years ago

I'm using Spring Framework installed with Spring Tools and when i add the jlibtorrent dependency it all works well. The jar is here on maven dependancies. Spring even finds the autoimports. But when I want to use something from jlibtorrent it trows me this warn "Resolved exception caused by Handler execution: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent" I got java 1.8 and the same error happens in osx and windows.

aldenml commented 6 years ago

I never tested the library in a servlet container, in the past I remember that some care should be taken when dealing with native code related to memory handling and creation of components. Well, what I see is that you are not copying the native libraries. Grab https://search.maven.org/remotecontent?filepath=com/frostwire/jlibtorrent-macosx/1.2.0.16-RC1/jlibtorrent-macosx-1.2.0.16-RC1.jar and https://search.maven.org/remotecontent?filepath=com/frostwire/jlibtorrent-windows/1.2.0.16-RC1/jlibtorrent-windows-1.2.0.16-RC1.jar and uncompress them as regular zip files. You will get a .dylib and a .dll. Place them in the appropriated place for your servlet container. Let me know the results.

PulsarFox commented 6 years ago

Hm i'm a bit of a newbie at springtool but I tried to add a Configuration class with SpringBootServletInitializer and load the library in it but nothing changes. The configuration is loaded but the error type is the same.

aldenml commented 6 years ago

did you uncompress the native library? what OS are you testing at the moment?

PulsarFox commented 6 years ago

Yes I unzipped it and I tested it on macosx Sierra 10.12.6

aldenml commented 6 years ago

Where did you put the libjlibtorrent.dylib file?

PulsarFox commented 6 years ago

I tested on the same folder as the conf class, the project root, the resources folder I even linked the path to the library to the conf class

aldenml commented 6 years ago

(you can correct me if I'm wrong) Is this Spring Tools an eclipse based IDE, right? if that's the case, you should open the run configuration and set your native library path -Djava.library.path=<path here> to the location when you extracted the .dylib. For deployment in production is another story, let me know.

PulsarFox commented 6 years ago

I think it works now. I added the jar manually and specified the source and the library path to the right files. Also i didn't install the macosx version because it was throwing me a Classdefnotfound exception. Thank you for your time (and your superapp of course) and i'll keep you in touch if something goes wrong !

aldenml commented 6 years ago

Reopen if you need to

procnet0 commented 6 years ago

Hello , i am working with PulsarFox. We managed to bind the Jar manually. Actually we can download the video file form a .torrent. But it seems that some class used in the Example can't be found : likes Utils Files , Hex, Logger and i can't find how load them. Thanks for your time and your help.

screen shot 2018-01-29 at 6 48 56 pm

aldenml commented 6 years ago

That classes are private and internal to jlibtorrent, not intended for external use. You can replicate their features with any apache commons library, or just copy the source code from the repo.

aldenml commented 6 years ago

btw, in the screenshoot I see a mix of 1.2.0.6-RC3 for the sources and that you are using 1.2.0.16-RC3 for the binary. You can use 1.2.0.16 now and maven/gradle should pull the corresponding source.

procnet0 commented 6 years ago

Ok i will try it thank you very much :)

Edit: Maven import still cause linkage error or NoClassDefFoundError Could not initialize class com.frostwire.jlibtorrent.swig.libtorrent_jni.. we will keep the manual binding way for the moment.