java-native / jssc

Java library for talking to serial ports (with added build support for maven, cmake, MSVC)
https://discord.gg/RBsUfE9sX9
GNU Lesser General Public License v3.0
164 stars 53 forks source link

Exception when opening port #164

Closed athach closed 8 months ago

athach commented 8 months ago

Hello, Thank you very much for your work and sharing it.

I moved from 2.8.0 to 2.9.6 and now I get an exception when opening a port: "SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"."

I had a look inside the jar and there are slf4j files in there. Am I supposed to include something more?

Thanks

pietrygamat commented 8 months ago

This is the same as #76. It should not be a critical problem, so if it prevents you from opening port, please share more details / stack trace.

athach commented 8 months ago

Thank you. I included the library and the error message is gone. Before posting here I did try that but with a more recent version of slf4j and that did not work. Maybe you should make a note about this on the front page for other users.

tresf commented 8 months ago

Thank you. I included the library and the error message is gone. Before posting here I did try that but with a more recent version of slf4j and that did not work. Maybe you should make a note about this on the front page for other users.

This will depend where you get the library. On our downloads page, it should never appear however from Maven it will. This is because Maven requires the transient dependencies to be resolved by the build system whereas our download should contain everything needed to use the library.

Where did you download it from? If it was from our downloads area, that's a bug.

athach commented 8 months ago

It was downloaded from https://github.com/java-native/jssc/releases/tag/v2.9.6

tresf commented 8 months ago

@athach from my testing against v2.9.6, this is not an Exception, but rather a benign message logged to stderr. Here's my code:

public class MainJssc {
    public static void main(String... args) {
        System.out.println(Arrays.toString(SerialPortList.getPortNames()));
    }
}

This is the same as https://github.com/java-native/jssc/issues/76. It should not be a critical problem, so if it prevents you from opening port, please share more details / stack trace.

This seems to be accurate. Here's my output:

- SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
- SLF4J: Defaulting to no-operation (NOP) logger implementation
- SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  [/dev/cu.Bluetooth-Incoming-Port, /dev/cu.wlan-debug, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.wlan-debug]

No exceptions are thrown in this example. I believe the long-term plan is to remove native-lib-loader as a project dependency which will remove the transient dependency on slf4j. With regards to documenting this, we're welcome to recommendations on how to present this to the user on the project page.

athach commented 8 months ago

I am sorry. You are correct, it is not an exception.