tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

When i try to use tdlin in tomcat library native crash #2528

Closed nicolasfarina closed 1 year ago

nicolasfarina commented 1 year ago

Hi, I'm trying to run the example on a tomcat application server to be able to send telegram messages. What happens is that when the library tries to reload "tdblib" I get the following error. And so that it does not happen again I have to restart the tomcat.

image

levlam commented 1 year ago

See https://stackoverflow.com/questions/36936948/java-lang-unsatisfiedlinkerror-native-library-xxx-so-already-loaded-in-another.

nicolasfarina commented 1 year ago

I tried to do that and it didn't work, the posts are very old.

levlam commented 1 year ago

The answers on StackOverflow are correct and exactly descibe the cause of the issue with some solutions. You can find the code, which loads libtdjni at https://github.com/tdlib/td/blob/66234ae2537a99ec0eaf7b0857245a6e5c2d2bc9/example/java/org/drinkless/tdlib/Client.java#L16-L22

You need to modify the code as suggested in the answers.

Juanma1106 commented 1 year ago

Hi @levlam , we try to do that.

Here is the code: image

Inside conf, in file catalina.properties, we have this: image

In /opt/tomcat/shared/lib we put the native library "libtdjni.so". image

When we deploy the war in tomcat the first time, it's all ok, but when we try to deploy again (cp ...war /opt/tomcat/fastprg/), we have the next error: image

levlam commented 1 year ago

You need to remove library loading code from Client.java.

Juanma1106 commented 1 year ago

If we remove this load, we have the problema that the tomcat never load the library image

The error we have when we try to create the client is: image

levlam commented 1 year ago

You must load the library manually from a proper place.