I’m not sure if this applies outside Eclipse or not, but in Eclipse at least, the Felix Gogo console (a very basic version of the Karaf console) is in the same window as the log output. It makes it virtually impossible to work with, when you have listed something and want to look up individual entries, you end up having to scroll 500 lines to find what you “just printed” above. Also, the log writes where you write, so writing anything but very short commands is very difficult (only what you type “counts”, but visually on the screen, you can’t see what you typed earlier, or it’s all mixed up). In short, this has turned me slightly mad at times, and after a lot of hours, I’ve finally figured out how to split them. I make this thread to share my findings.
I found no way to split them inside Eclipse itself, but I discovered that it’s possible to get Felix Gogo to listen on a network socket. It supports SSH, but I have no idea where to configure certificates, users, etc., and no desire to find out, so I went with good old Telnet. There’s no “risk” involved in somebody gaining access to a very restricted OSGi console on a test installation I use for development, so there’s no reason to make it more complicated than necessary.
The other Felix bundles are injected as Maven artifacts by a Maven plugin, which also controls the versions, so it’s a bit of a guessing game to figure out what version to use, but the version I found works with the current set of Felix bundles. In launch/app/pom.xml, add this dependency:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.shell.remote</artifactId>
<version>1.2.0</version>
</dependency>
Make sure to have Maven download it by building the demo app, or by using Maven → Update Project, or some other way. The important thing is that it’s available by the time you try to “resolve” the bndrun file.
In app.bndrun, add osgi.identity;filter:='(osgi.identity=org.apache.felix.shell.remote)' to the feature.debug section so that it looks like this:
feature.debug: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.webconsole)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.webconsole.plugins.ds)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.shell.remote)'
Then, in the -runproperties: sections, add:
osgi.shell.telnet.ip=0.0.0.0,\
osgi.shell.telnet.port=1111
Make sure to add ,\ to the end of the previous line if you append this to existing runproperties.
You can bind to any IP you like and might use a loopback if you want to restrict access. Likewise, you can use whatever port you like, but on Linux/macOS, you probably want to stay above 1024, or the demo app will have to run as root. The standard Telnet port 23 is thus not ideal.
Once this is done and app.bndrun has been saved, you need to “resolve” it so that the new bundle is included in -runbundles:. Once resolved and saved, launch a debug session normally.
Every time you start the demo app from now on, it will listen to the IP/port that you defined. You can use any Telnet-capable client to connect and run the Felix Gogo console without the log output flooding everything you try to do.
I found that there are a couple of widespread issues with most Telnet clients though. The Felix Gogo console arrogantly ignores what platform it runs on, so it uses LF only as newline. Surprisingly few Telnet clients for Windows can handle this, which results in any output basically being one long line, which makes it impossible to read. My beloved PuTTY can be configured to handle it, but it has another fatal flaw: no horizontal scrollbars.
While I assume that the newline problem is Windows only, the other problem is that the Telnet clients all want to wrap long lines. I assume that this applies to all platforms. The output when you list bundles can be quite long for example, and line wrapping will just make a complete mess of the output. I want it to behave like the Eclipse console does, with essentially unlimited line length and horizontal scrolling available should you need that. I’ve failed to find something that allows that and can handle newlines, but I’ve gotten pretty close with Tera Term. It’s Windows only though, but since I assume the newline problem isn’t an issue with other platforms, the available options might be better. Eclipse can actually open a Telnet client itself by opening a “Terminal” and selecting Telnet, but ironically, it can’t handle the newlines either.
Regardless, I now finally have a Felix Gogo console that I can actually work with.
