OSGI Resource not found

Hi ALl,

I’m using JBoss Fuse as OSGI container and trying to deploy Vaadin V13. I have some problem regarding static resources deployed via the OsgiVaadinStaticResource service. When I follow the online tutorial regarding OSGI deployment I get the following resources deployed on the following http endpoints :

108│ResourceServlet│/VAADIN/static/client:/META-INF/resources/VAADIN/static/client│Deployed│/VAADIN/static/client│
[/VAADIN/static/client/*]

108│ResourceServlet│/VAADIN/static/push:/META-INF/resources/VAADIN/static/push│Deployed│/VAADIN/static/push│
[/VAADIN/static/push/*]

108│ResourceServlet│js│Deployed│/frontend/comboBoxConnector.js│
[/frontend/comboBoxConnector.js/*]

108│ResourceServlet│js│Deployed│/frontend/contextMenuConnector.js│
[/frontend/contextMenuConnector.js/*]

108│ResourceServlet│js│Deployed│/frontend/datepickerConnector.js│
[/frontend/datepickerConnector.js/*]

108│ResourceServlet│html│Deployed│/frontend/flow-component-renderer.html│
[/frontend/flow-component-renderer.html/*]

108│ResourceServlet│js│Deployed│/frontend/gridConnector.js│
[/frontend/gridConnector.js/*]

108│ResourceServlet│js│Deployed│/frontend/ironListConnector.js│
[/frontend/ironListConnector.js/*]

108│ResourceServlet│css│Deployed│/frontend/ironListStyles.css│
[/frontend/ironListStyles.css/*]

108│ResourceServlet│js│Deployed│/frontend/timepickerConnector.js│
[/frontend/timepickerConnector.js/*]

108│ResourceServlet│html│Deployed│/frontend/vaadin-grid-flow-selection-column.html│
[/frontend/vaadin-grid-flow-selection-column.html/*]

108│ResourceServlet│png│Deployed│/icons/icon.png│
[/icons/icon.png/*]

It seems that resources are well deployed but when I try to call one of this endpoint I get a “Not Found”. For me it makes sense that resources are not found because the bundle deploying the resource is the bundle “108” (com.vaadin.flow.osgi) which doesn’t have access to resources in bundle which contains the resource (-> com.vaadin.flow.client, com.vaadin.flow.push ,…).
Does anydbody get the same error ? Did anybody successfully deploy Vaadin on Jbos Fuse? What do you have when you execute a http:list in your osgi console?

Many thanks for responses or suggestions :wink:

Hi,
if the problem is still pending: resources can only be loaded with the correct wrapping as OSGi service of class OsgiVaadinStaticResource. If you have an OSGI-INF component descriptor referenced in your manifest, you should be able to load the resource by its path (not alias).
The wrapping looks like this:

import com.vaadin.flow.osgi.support.OsgiVaadinStaticResource;
import org.osgi.service.component.annotations.Component;

@Component(immediate = true, service = OsgiVaadinStaticResource.class)
@SuppressWarnings("all")
public class ResourceLogo implements OsgiVaadinStaticResource {
  @Override
  public String getPath() {
    return "/META-INF/resources/logo.png";
  }
  
  @Override
  public String getAlias() {
    return "/logo.png";
  }
}

The component descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="geo.resources.ResourceLogo" immediate="true">
  <service>
    <provide interface="com.vaadin.flow.osgi.support.OsgiVaadinStaticResource"/>
  </service>
  <implementation class="geo.resources.ResourceLogo"/>
</scr:component>

You can load it from any OSGi bundle that can bind the service like this:

  public MyLayout() {
    Image img = new Image("/META-INF/resources/logo.png" , "Vaadin Logo");
    img.setHeight("44px");
    addToNavbar(new DrawerToggle(), img);
	...

Cheers