Java spring-shell-standard cli program failed to perform only under Snap

Hi all! I have a Java cli program that uses the spring-shell-standard library. Some of the features of this library is to auto complete shell command and changing the color of the text.

Everything worked fine until lately, we discovered that new snap versions we build are not working as usual (old snap versions we already built in the past still working fine).

When I running it not under Snap, everything works.

The only things we changed in the way we build our snap is: Added to the snapcraft yaml base:core18 due to a change in snapcraft that requires this setting. And running the snapcraft with --use-lxd due to an multipass error. According to the following:

also tried with --provider=host --destructive-mode

Please help, Thanks in advance!

I have created a simple example and I payed attention that the spring-shell-standard uses jline-terminal is throwing a warning only when it’s running under snap.

WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)

This warning can explain why I experience lack of special features, such as bold and blinking characters.

But why it “Unable to create a system terminal” under Snap? see:


After some debugging, I got the specific error:

WARNING: Creating a dumb terminal
java.lang.IllegalStateException: Unable to create a system terminal
        at org.jline.terminal.TerminalBuilder.doBuild(
            at App.main(
        Suppressed: java.lang.NoClassDefFoundError: com/sun/jna/Platform
                at org.jline.terminal.impl.jna.JnaNativePty.current(
                at org.jline.terminal.impl.jna.JnaSupportImpl.current(
                at org.jline.terminal.TerminalBuilder.doBuild(
                ... 2 more
        Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
                at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
                at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
                at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
                ... 5 more
        Suppressed: java.lang.UnsupportedOperationException
                at org.jline.terminal.impl.jansi.JansiSupportImpl.current(
                at org.jline.terminal.TerminalBuilder.doBuild(
                ... 2 more
        Suppressed: Not a tty
                at org.jline.terminal.impl.ExecPty.current(
                at org.jline.terminal.TerminalBuilder.doBuild(
                ... 2 more
        Caused by: Error executing 'tty': not a tty
                at org.jline.utils.ExecHelper.exec(
                at org.jline.terminal.impl.ExecPty.current(
                ... 3 more

Also, when I’m running snap run --shell <SnapName> and run tty command I’m getting “not a tty”. What is the reason? does it changed lately?


Solved by adding to the command < /dev/tty e.g java -jar myjar.jar < /dev/tty