jnr / jnr-unixsocket

UNIX domain sockets (AF_UNIX) for Java
Apache License 2.0
278 stars 75 forks source link

java.lang.UnsatisfiedLinkError: ÕҲ »µ½ ָ¶¨µ #83

Closed Wenenen closed 4 years ago

Wenenen commented 4 years ago

When I run the UnixServer sample on windows, it reports java.lang.UnsatisfiedLinkError: ÕҲ »µ½ ָ¶¨µ error. The path of the UnixServer sample is jnr-unixsocket/src/test/java/jnr/unixsocket/example/UnixServer.java Exception in thread "main" java.lang.UnsatisfiedLinkError: ÕҲ»µ½ָ¶¨µ at jnr.ffi.provider.jffi.AsmRuntime.newUnsatisifiedLinkError(AsmRuntime.java:40) at jnr.unixsocket.Native$LibC$jnr$ffi$0.socket(Unknown Source) at jnr.unixsocket.Native.socket(Native.java:92) at jnr.unixsocket.UnixServerSocketChannel.(UnixServerSocketChannel.java:38) at jnr.unixsocket.UnixServerSocket.(UnixServerSocket.java:32) at jnr.unixsocket.UnixServerSocketChannel.open(UnixServerSocketChannel.java:48) at com.delilegal.IPC.UnixServer.main(UnixServer.java:23)

headius commented 4 years ago

I would not expect this library to work at all on Windows since there's no unix socket support there. The error is pretty weird but even without that it wouldn't work anyway.

headius commented 4 years ago

So I think the only thing to do here would be to make the error more explicit about not working on Windows. Despite the odd error, this is failing to locate the "socket" function. I will look into improving that error and also making jnr-unixsocket report that it can't run on Windows.

headius commented 4 years ago

If you get a chance, can you run this passing -Djnr.ffi.asm.enabled=false to the JVM? It would get me a better stack trace. I don't have Windows handy at the moment.

headius commented 4 years ago

Thank you @enebo for providing the longer trace I requested above:

java.lang.UnsatisfiedLinkError: native method 'socket' not found for method public abstract int jnr.unixsocket.Native$LibC.socket(int,int,int)
        at jnr.ffi.provider.jffi.DefaultInvokerFactory$FunctionNotFoundInvoker.invoke(DefaultInvokerFactory.java:466)
        at jnr.ffi.provider.NativeInvocationHandler.invoke(NativeInvocationHandler.java:47)
        at com.sun.proxy.$Proxy6.socket(Unknown Source)
        at jnr.unixsocket.Native.socket(Native.java:92)
        at jnr.unixsocket.UnixServerSocketChannel.<init>(UnixServerSocketChannel.java:43)
        at jnr.unixsocket.UnixServerSocket.<init>(UnixServerSocket.java:32)
        at jnr.unixsocket.UnixServerSocketChannel.open(UnixServerSocketChannel.java:53)
        at jnr.unixsocket.UnixSocketChannelTest.startServer(UnixSocketChannelTest.java:95)
        at jnr.unixsocket.UnixSocketChannelTest.testInterruptRead(UnixSocketChannelTest.java:59)

On that system it appears that the encoding of the string is correct, but I do not see your original error in the issue report. What code page or encoding do you have configured on Windows? I suspect it's a multi-byte encoding that's getting mangled in our error message here.

In any case, there's only two things to fix:

Wenenen commented 4 years ago

So I think the only thing to do here would be to make the error more explicit about not working on Windows. Despite the odd error, this is failing to locate the "socket" function. I will look into improving that error and also making jnr-unixsocket report that it can't run on Windows.

Thank you very much for replying to this question. I have just learned that windows does not support unix domain socket. I want to run unix domain socket on windows mainly because my development environment is windows, but my running environment is linux, so I am switching the development environment to a linux server, hoping to run normally there.

headius commented 4 years ago

@Wenenen Good luck!