[dev] vaadin 14 with osgi and karaf

 After vaadin changed to the new flow technology it needs more effort to migrate to a new major version then 8.


In my case it means to test how to get vaadin in karaf working.

Unfortunately there is no direct karaf support in vaadin and there is no example or documentation how to do it. But I found OSGi support since vaadin 13. An example project was not working as described in the documentation (https://github.com/vaadin/base-starter-flow-osgi). Even with different branches and tags I get dependency exceptions in the OSGi framework.

So I started creating a new configuration and project from scratch.

I used my docker image with karaf 6.2.6 installed and java 11.0.3 to create a sample project and a bundle configuration.

You can checkout the project within my example project (https://github.com/mhus/mhus-examples) in folder vaadin-flow/mhu-vaadin-examples1. Compile the sources with maven:

git clone https://github.com/mhus/mhus-examples.git
cd mhus-examples/vaadin-flow/mhu-vaadin-examples1
mvn install

and follow the instructions in readme.txt:

First start the docker container and wait while the install process is finished:

docker run -it --name vaadin-flow \
 -h flow \
 -p 8181:8181 \
 -v ~/.m2:/home/user/.m2 \
 mhus/apache-karaf:4.2.6_01

Now you see the karaf prompt. Insert:

feature:install http-whiteboard

# deps
install -s mvn:com.vaadin.external/gentyref/1.2.0.vaadin1
install -s mvn:com.vaadin.external.gwt/gwt-elemental/2.8.2.vaadin2
install -s mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/1.2.1
install -s mvn:org.ow2.asm/asm/6.2.1
install -s mvn:org.ow2.asm/asm-tree/6.2.1
install -s mvn:org.ow2.asm/asm-commons/6.2.1
#deps
install -s mvn:com.helger/ph-commons/9.3.4
install -s mvn:com.helger/ph-css/6.2.0
install -s mvn:net.bytebuddy/byte-buddy/1.9.15
#install -s mvn:commons-io/commons-io/1.4
install -s mvn:commons-io/commons-io/2.5
install -s mvn:org.jsoup/jsoup/1.11.3
install -s mvn:commons-fileupload/commons-fileupload/1.4
# flow
install -s mvn:com.vaadin/flow-server/2.0.5
install -s mvn:com.vaadin/flow-osgi/2.0.5
install -s mvn:com.vaadin/flow-client/2.0.5
install -s mvn:com.vaadin/flow-data/2.0.5
install -s mvn:com.vaadin/flow-push/2.0.5
install -s mvn:com.vaadin/flow-html-components/2.0.5
# theme
install -s mvn:com.vaadin/vaadin-lumo-theme/2.0.5
# components
install -s mvn:com.vaadin/vaadin-button-flow/2.0.1
install -s mvn:com.vaadin/vaadin-notification-flow/2.0.0
install -s mvn:com.vaadin/vaadin-ordered-layout-flow/2.0.0

To install the dependencies and now install the example project:

install -s mvn:de.mhus.example.vaadin/mhu-vaadin-example1/1.0.0-SNAPSHOT

Set start level to 81 so it will be started after all the dependencies:

start-level mhu-vaadin-example1 81

And now restart the container. You can press Ctrl+D, wait until it stopped and start the container again with

docker start -ia vaadin-flow

If the start sequence is finished you can open the GUI in the browser

http://localhost:8181/gui/

In my case I see a button with an action. That's it!

Important:


  • It's not possible to link a vaadin UI to the root '/'
  • It's not possible to have two vaadin applications in the same engine. Only one vaadin UI is possible !
  • If you update the application bundle you need to restart the Vaadin Flow OSGi Support. (restart "Vaadin Flow OSGi Support")



Kommentare

Beliebte Posts aus diesem Blog

Sonatype Nexus fails with random "peer not authenticated" errors behind ingress

[mhus lib] Reorg in generation 7 nearly finished

Creating a flux sync configuration referring a config map for substitution