ARTICLES
Upgrading Karaf to 4.2.2 - Day 7
Last week I started replacing our forked Http Bridge with a more OSGi friendly and generic approach. I got to a point where it somewhat worked, but Vaadin UIs seem to have a problem with the new structure. So today I am going to investigate the issue some more.
Debugging the issue showed that the widgetset property, required for Vaadin UIs is not propagated properly, resulting in loading the DefaultWidgetSet which - for the Topology UI - is missing certain components.
We use a forked version of the Pax Vaadin project (see the extender-service for more details) to expose Vaadin UIs via OSGi.
The way this works is, a ServiceTracker is listening for ApplicationFactory services and then registers a custom version of the VaadinServlet to OSGi.
Looking at the code, it shows, that the widgetset property is actually set.
However, when instantiating the UI, the Vaadin DeploymentConfiguration does not have that information.
Refering to the Http Whiteboard Specification revealed the issue:
| Service Property | Type | Description |
|---|---|---|
servlet.init.* |
String (optional) |
Properties starting with this prefix are provided as init parameters to the |
It seems that here also the PAX Web project didn’t follow the OSGi specification.
Replacing all init.* properties with servlet.init solved the issue, and the Vaadin UIs now load.
However a new issue is shown:
With the change, all UIs immediately timeout and say "Session Expired".
This is odd.
Debugging the Apache Felix WhiteboardManager code revealed that for each request a new session was created.
So the previous session was not reused.
That explains the "Session Timeout".
But this is an issue I cannot simply solve, so I looked for a newer version of the Apache Felix HTTP project and hoped that it will solve the issue. I found a newer version 4.0.4, which seem to have the issue fixed, by looking at the code. As this looked promising, I updated to use version 4.0.4 instead of 3.0.0. This required some more work, as the Proxy project does not have a newer version, but was mostly simple to do.
With the new version the session no longer expires immediately when navigating a Vaadin UI.
This is good news.
I tried to verify if this is now working for all Vaadin UIs and not only working for the Topology Map. While doing that I encoutered the issue, that the first Vaadin UI I accessed, was always beeing provided to me. To clarify this a bit more.
If I go to the JMX Configuration UI the JMX UI is presented to me. Now if I navigate to the Topology Map the JMX UI is also presented to me.
I investigated the issue some more, but comment in the OpenNMS Dev Channel summaries the problem pretty good (mvrueden, 25th February 2019, 18:13 CET):
Found an interesting issue with our current Vaadin implementation It seems that each time you visit a Vaadin application, a new UI is created and not reusing the existing one. In most UIs this is probably not a problem, but it will definetly result in a memory leak at some point, or at least it will blow up the user’s session unnecessary. For example, if you go to Admin → JMX Configuration and then refresh the page, multiple (in this case 2) instances of the UI are present on the server, whereas only one should be. The problem is caused by the way Vaadin "restores" the session. It does that by the application’s id and the window.name property. This identifies the application uniquely. However if the window.name is not set, it will randomly generate one. And of course if you refresh the page, you will either get the wrong one (depending which vaadin UI you visited first) or you get a new one each time (in case of iframes). In some cases we set the name (via <iframe name=../>), which then is no problem.
Just to clarify, that these were my first findings and thoughts and later on do not fully turn out to be true.