vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
590 stars 163 forks source link

Flow-server has runtime dependency to license-checker in OSGI #17675

Open shakanen opened 10 months ago

shakanen commented 10 months ago

Description of the bug

When deploying flow-feature and specifically flow-server bundle to OSGI-container there is a dependency to package com.vaadin.pro.licensecheck. Based on #13922 and https://github.com/vaadin/flow/issues/13922#issuecomment-1148483787 I understand that it's not a runtime dependency. If the runtime dependency can be excluded/is optional for other ways of deploying flow-server, it should be at least optional in OSGI.

Without this package present installing flow-server feature fails with

karaf@root()> feature:install flow-server/23.3.20
org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=flow-server; type=karaf.feature; version="[23.3.20,23.3.20]"; filter:="(&(osgi.identity=flow-server)(type=karaf.feature)(version>=23.3.20)(version<=23.3.20))" [caused by: Unable to resolve flow-server/23.3.20: missing requirement [flow-server/23.3.20] osgi.identity; osgi.identity=com.vaadin.flow.server; type=osgi.bundle; version="[23.3.20,23.3.20]"; resolution:=mandatory [caused by: Unable to resolve com.vaadin.flow.server/23.3.20: missing requirement [com.vaadin.flow.server/23.3.20] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.vaadin.pro.licensechecker)(version>=1.12.0)(!(version>=2.0.0)))"]]

I can maybe help with PR to omit/make this package dependency optional.

Expected behavior

The feature installation should not fail, at least because of something that is not even needed. Documentation in https://vaadin.com/docs/latest/integrations/osgi/karaf#karf.features does not mention the requirement to install license-checker, it's location or anything.

Minimal reproducible example

Follow documentation to install flow to karaf, https://vaadin.com/docs/latest/integrations/osgi/karaf#karf.features

Have a base apache-karaf e.g. 4.3.9 Install dependency features feature:install spifly http-whiteboard Install dependency bundle:install mvn:org.slf4j/slf4j-simple/1.7.36

Install flow-server features repo feature:repo-add mvn:com.vaadin/flow/23.3.20/xml/features Install flow-server feature feature:install flow/23.3.20

Copy/paste

feature:install spifly http-whiteboard
bundle:install mvn:org.slf4j/slf4j-simple/1.7.36
feature:repo-add mvn:com.vaadin/flow/23.3.20/xml/features
feature:install flow/23.3.20

Versions

mshabarov commented 10 months ago

OSGi add-on is a commercial feature in Vaadin. License checking happens in dev mode at runtime. I'm not surely at the moment that we can safely make the license-checker optional, because of the above reasons. But I'd like to keep this issue opened for further analysis.

shakanen commented 9 months ago

This request is not related to osgi-addon. If that addon requires the license-checker classes in runtime then it should have a dependency to them. Unless the flow-server itself requires the license-checker classes at runtime, it should not have dependency to them. I looked at the headers of vaadin-osgi-integration 8.16.1 and it's not a fragment-bundle of flow-server and neither does it import the package com.vaadin.flow.server.frontend that has the class that uses LicenseChecker. Based on this it seems that the package-dependency is not needed at runtime and could be optional. If not, maybe the documentation should note that the bundle for license-checker is needed or the flow-feature could install it.

mshabarov commented 9 months ago

Ah, I see your point, so you're talking about flow-server being deployed into OSGi container apart from/without Vaadin OSGi add-on. Then I think the license checker indeed should be optional. (except maybe for Vaadin 22.1, as it has requires Vaadin license, even for Flow).