taksan / skype-java-api

Skype API for Java, based on Skype4Java library
128 stars 57 forks source link

Can't load a libskype*_x86.so #22

Closed taktos closed 9 years ago

taktos commented 11 years ago

Hello, I'm running this on Ubuntu 32bit and got an error below.

java.lang.IllegalStateException: Library libskype_x11_skype_x86.so is not in the resource path! This is a bug!
        at com.skype.connector.ConnectorUtils.loadLibrary(ConnectorUtils.java:77)
        at com.skype.connector.linux.SkypeFramework.init(SkypeFramework.java:58)
        at com.skype.connector.linux.LinuxConnector.isRunning(LinuxConnector.java:61)

I renamed the 'libskype_x11_x86.so' to 'libskype_x11_skype_x86.so', the error didn't recur. I think the argument value on SkypeFramework.java:58 is invalid: ConnectorUtils.loadLibrary(getLibName("skype_x86")); would be ConnectorUtils.loadLibrary(getLibName("x86"));

helloworld121 commented 11 years ago

Hi taktos, I am facing the same problem. Did you found a solution? Thank you very much, Sebastian

taksan commented 11 years ago

Sorry it took so long to reply. Taktos is right, the second line is correct. I just commited the fix.

evluhin commented 11 years ago

could you please create a minor (or major release) with fixes of 21 and 22 issues, since it's impossible to build projects via maven on MacOs (possible but it isn't work)?

taksan commented 11 years ago

Yes. I have just released it now. It might take some time for the 1.5 version to show up, I'd check an hour from now.

helloworld121 commented 11 years ago

Hi taksan,

thank you very much for the fast answer. But I still get a similar problem: 13:33:22,237 ERROR SkypeContextListener:37 - Loading libskype_dbus_x86.so failed. /opt/test/apache-tomcat-6.0.36/temp/libskype_dbus_x864667399785205820830.so: libdbus-glib-1.so.2: cannot open shared object file: No such file or directory com.skype.SkypeException: Loading libskype_dbus_x86.so failed. /opt/test/apache-tomcat-6.0.36/temp/libskype_dbus_x864667399785205820830.so: libdbus-glib-1.so.2: cannot open shared object file: No such file or directory at com.skype.Utils.convertToSkypeException(Utils.java:61) at com.skype.Skype.addChatMessageListener(Skype.java:770)

The file exists in this directory: /usr/lib64/libdbus-glib-1.so.2

Do you know what my mistake is?

Thank you very much, Sebastian

taksan commented 11 years ago

Hi

Well, this not a similar problem, because the previous problem meant skype-api didn't find the libskype library and now it is not finding another library when trying to open libskype

You can try the following: add /usr/lib64 directory to your LD_LIBRARY_PATH variable before running the application using skype-api. Please, report back whether it works.

Thanks

helloworld121 commented 11 years ago

Hi taksan,

I added the following line: export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH

But now I get this exception: 14:15:08,770 ERROR SkypeContextListener:37 - Loading libskype_dbus_x86.so failed. /opt/test/apache-tomcat-6.0.36/temp/libskype_dbus_x864857172945887706157.so: libdbus-glib-1.so.2: wrong ELF class: ELFCLASS64 com.skype.SkypeException: Loading libskype_dbus_x86.so failed. /opt/test/apache-tomcat-6.0.36/temp/libskype_dbus_x864857172945887706157.so: libdbus-glib-1.so.2: wrong ELF class: ELFCLASS64 at com.skype.Utils.convertToSkypeException(Utils.java:61) at com.skype.Skype.addChatMessageListener(Skype.java:770)

Do you have also an idea how to fix this?

taksan commented 11 years ago

Now that I paid more attention to the error message, it says: 14:15:08,770 ERROR SkypeContextListener:37 - Loading libskype_dbus_x86.so failed. Therefore, you are probably using a 32bit linux. So, that's the reason why /usr/lib64 wasn't found. Now that you added, it is not loading because it is trying to load a 64bit shared library on a 32bit linux.

You need to install dbus glib libraries for a 32bit linux. That should handle the problem.

helloworld121 commented 11 years ago

I executed the command: "uname -a" and it prints the following line: Linux SERVERNAME 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux Isn't this a 64bit linux?

But when I execute "java -d64 -version". I get the following message: Running a 64-bit JVM is not supported on this platform.

Does this mean my Java is 32bit and I have to install a 64bit java?

taksan commented 11 years ago

Yes, that must be the problem. Because that's 32bit java it is mixing 32bit libraries with 64bit

helloworld121 commented 11 years ago

Hi taksan,

thank you very much, now it looks much different. But it is still not working :(

Now there is the following error: \ ERROR **: g_thread_init() must be called before dbus_threads_init() aborting...

Do you have an idea hwo I could fix this problem?

Thanks, Sebastian

taksan commented 11 years ago

What program are you using to test? Is this one of the examples or your own program?

helloworld121 commented 11 years ago

I wrote a ServletContextListener that should run inside a Servlet-Container (I used a Tomcat). It works on a Windows 7 system, but on CentOS the error I described above is thrown. This is the Listener:


public class SkypeContextListener
        implements ServletContextListener {
    private Logger log = Logger.getLogger(getClass());    
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        log.warn("Calling");
        try {
            Skype.setDaemon(false); // to prevent exiting from this program
            Skype.addChatMessageListener(new ChatMessageAdapter() {
                public void chatMessageReceived(ChatMessage received) throws SkypeException {
                    if (received.getType().equals(ChatMessage.Type.SAID)) {
                        log.info("sender: " + received.getSender());
                        log.info("content: " + received.getContent());
                    }
                }
            });
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }
}
taksan commented 11 years ago

Now, that's really odd. Have you tried the examples to check whether you get the same error?

helloworld121 commented 11 years ago

Hi taksan, sorry my answer took so long. I tested it on the linux system and got the same error.

I compiled the sample on the console using javac and started the program but the same error is thrown:

\ ERROR **: g_thread_init() must be called before dbus_threads_init() aborting... Aborted

This is the class:


import com.skype.ChatMessage;
import com.skype.ChatMessageAdapter;
import com.skype.Skype;
import com.skype.SkypeException;
/**
 * https://github.com/taksan/skype-api-samples/tree/master/src/main/java/com/skype/sample
 */
public class AutoAnswering {
    public static void main(String[] args) throws Exception {
        Skype.setDaemon(false); // to prevent exiting from this program
        Skype.addChatMessageListener(new ChatMessageAdapter() {
            public void chatMessageReceived(ChatMessage received) throws SkypeException {
                if (received.getType().equals(ChatMessage.Type.SAID)) {
//                    received.getSender().send("I'm working. Please, wait a moment.");
                    System.out.println("sender: " + received.getSender());
                    System.out.println("content: " + received.getContent());
                    received.getSender().send("echo");
                }
            }
        });
    }
}
taksan commented 11 years ago

I was researching into it and I believe the problem is probably due to an old version of glib, because g_thread_init is deprecated since version 2.32.

Could you please check what is you glib version?

helloworld121 commented 11 years ago

Hi taksan,

I think I am using no glib. Do you mean glibc?

This is the output of "rpm -q glibc" glibc-2.12-1.80.el6_3.6.x86_64 glibc-2.12-1.80.el6_3.6.i686

taksan commented 11 years ago

I'm talking about libglib2.0, which is a gnome library, not glibc.

helloworld121 commented 11 years ago

Ahh, sorry. Output of "rpm -q glib2" is: glib2-2.22.5-7.el6.x86_64 glib2-2.22.5-7.el6.i686

taksan commented 11 years ago

There you have it. Unfortunately, when I developed the dbus connector, it was for glib2 2.34 and above, because g_thread_init is deprecated as of 2.34 (because it is automatically invoked).

You have some options to proceed without waiting for me. 1) upgrade your glib2 to 2.34 or later 2) set the system property "skype.api.impl" to "x11"

The second option will make skype-api use the x11 strategy to communicate with skype. The x11 strategy has several problems and is less stable, but at least you might move forward and make your tests.

As for me, I'll think of a solution. Maybe I'll just use the deprecated API or I'll write a new strategy using dbus. I'll see how to address the problem to make skype-api work with older glib2 apis.

helloworld121 commented 11 years ago

Hi taksan :)

thank you again. I am using the latest centos and this latest glib2 that is provided.

I used the system property as you said and now the server starts and receives the requests :D

But there is one problem left. On each skype message there is an Exception in the logfile:


Exception in thread "AsyncSkypeMessageSender-8" java.lang.NullPointerException
        at com.skype.ChatMessageConnectorListener.messageReceived(ChatMessageConnectorListener.java:23)
        at com.skype.connector.Connector.fireMessageEvent(Connector.java:1119)
        at com.skype.connector.Connector.access$500(Connector.java:37)
        at com.skype.connector.Connector$13.run(Connector.java:1098)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
18:04:12,923  INFO SkypeContextListener:32 - sender: my-user
18:04:12,925  INFO SkypeContextListener:33 - content: test

Do I have to worry? This is the output from the ServeletListener I posted above.

Thanks again! :)

taksan commented 11 years ago

This is a bug, for sure. I'll get it fixed. Anyway, it wont't be such a big deal for you.

taksan commented 9 years ago

The actual bug in the issue was fixed. As for the NPE, another issue should be opened to deal with that.