Karaf console throws error when logging in and exits

When I try to access the karaf console, I have the following symptom:

  • ssh openhab@localhost -p 8101
  • I enter the pw: hab…
  • It seems to login as it shows the openhab ascii logo and shows the text that explains what you can do (“Hit tab…”)
  • but then it throws the following error

Error executing command: For input string: "1517090219544"
Connection to localhost closed.

and I I am thrown out again.

Any idea what the problem could be or how I can track down the problem?

Thanks in advance
Stefan

I am using

  • Hardware: rasp pi 3
  • OS: openhabian
  • openHAB version: 2.2.0

Maybe try the command line console. Connect with ssh and type

openhab-cli console

Thanks Josar,

I just did a minute ago (as desperate as I was) and got the same

Logging in as openhab

Password:

   __  _____    ____

____ ____ ___ ____ / / / / | / __ )
/ __ / __ / _ / __ / // / /| | / __ |
/ /
/ / // / __/ / / / __ / ___ |/ // /
_/ ./_// /// /// |/___/
/_/ 2.2.0
Release Build

Hit ‘’ for a list of available commands
and ‘[cmd] --help’ for help on a specific command.
Hit ‘’ or type ‘system:shutdown’ or ‘logout’ to shutdown openHAB.

Error executing command: For input string: “1517090219544”

cheers
Stefan

I have activated the karaf log and it produces the following exception

 2018-02-25 23:52:16.064 [ERROR] [apache.karaf.shell.support.ShellUtil] - Exception caught while executing command

   java.lang.NumberFormatException: For input string: "1517090219544"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]
at java.lang.Long.parseLong(Long.java:578) ~[?:?]
at java.lang.Long.parseLong(Long.java:631) ~[?:?]
at org.jline.reader.impl.history.DefaultHistory.lambda$load$0(DefaultHistory.java:87) ~[?:?]
at java.util.Iterator.forEachRemaining(Iterator.java:116) [?:?]
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) [?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) [?:?]
at org.jline.reader.impl.history.DefaultHistory.load(DefaultHistory.java:85) [14:org.jline:3.5.1.sp1]
at org.jline.reader.impl.history.DefaultHistory.attach(DefaultHistory.java:68) [14:org.jline:3.5.1.sp1]
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:475) [14:org.jline:3.5.1.sp1]
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:349) [11:org.apache.karaf.shell.core:4.1.3]

at java.lang.Thread.run(Thread.java:748) [?:?]

2018-02-25 23:52:16.064 [ERROR] [apache.karaf.shell.support.ShellUtil] - Exception caught while executing command

java.lang.NumberFormatException: For input string: "1517090219544"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]
at java.lang.Long.parseLong(Long.java:578) ~[?:?]
at java.lang.Long.parseLong(Long.java:631) ~[?:?]
at org.jline.reader.impl.history.DefaultHistory.lambda$load$0(DefaultHistory.java:87) ~[?:?]
at java.util.Iterator.forEachRemaining(Iterator.java:116) [?:?]
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) [?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) [?:?]
at org.jline.reader.impl.history.DefaultHistory.load(DefaultHistory.java:85) [14:org.jline:3.5.1.sp1]
at org.jline.reader.impl.history.DefaultHistory.attach(DefaultHistory.java:68) [14:org.jline:3.5.1.sp1]
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:475) [14:org.jline:3.5.1.sp1]
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:349) [11:org.apache.karaf.shell.core:4.1.3]

at java.lang.Thread.run(Thread.java:748) [?:?]
1 Like

Thanks for not giving up:
I cleared all the cache as described there but unfortunately the problem stays…

and I went on investigating:

What stroke me in the exception is that it tries to read the “DefaultHistory”. When I looked into the source of org.jline.reader.impl.history.DefaultHistory on github I got the feeling it tries to read the karaf history file but unfortunately I couldn’t directly find it until I finally got so desperate that I just searched the whole disc for “1517090219544” and I found the file. It is in the “hidden” directory “.karaf” (/var/lib/openhab2/.karaf) and is called “karaf41.history”.

I then looked into the file and it seems to be the history of the console and looks similar to this (“excerpt”)

1519062633979:feature:install openhab-transformation-regex
1519062646508:logout
1519073299907:feature:list
1519073335327:feature:list |
1519155183950:e
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@1517090219544:smarthome things list | more
1517090229723:smarthome things list
1517090233369:smarthome
1517090247942:smarthome things
151709 …

What is weird is actually the line that is “1517090219544” as it starts with ^@^@^@^…and it looks like this is some garbage that happened during a crash of the system…at least this does not belong there!

I fired up the editor, deleted all these crazy characters, saved the file and bingo, the console works again!

:smile: a good time to go to sleep now :smile: :zzz:

Could you add the full path to your description so someone with the same error can find it faster?

Absolutely: It is “/var/lib/openhab2/.karaf”