Search code examples
springspring-bootvaadinembedvaadin8

Embedding Vaadin + Springboot application into a Vaadin UI using Emdedded UI add-on


I am currently working on microservices using springboot and Vaadin 8, and I want to use Embedded UI 2.0 add-on for Vaadin.
I first tried embedding a simple Springboot + Vaadin into a host Vaadin application as shown in the example.
Here's the result code for the host application :

import ...
import org.vaadin.embedded.VaadinUIComponent;


@Theme(ValoTheme.THEME_NAME)
public class HostUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) { 
    /*My Spring boot application */      
    VaadinUIComponent ui1 = new VaadinUIComponent("http://localhost:8081/app2/");
    ui1.setSizeFull(); 
    /* A simple vaadin application*/ 
    VaadinUIComponent ui2 = new VaadinUIComponent("http://localhost:9020");

    HorizontalSplitPanel split = new HorizontalSplitPanel(ui1, ui2);
    split.setSizeFull();
    setContent(split);
}

But I keep having an issue with VAADIN/* resources loading :

{"timestamp":1501683162735,"status":404,"error":"Not Found","message":"No message available","path":"
/app2/widgetsets/ws84167e472e91ff0ea8255f8f1b189aa0/ws84167e472e91ff0ea8255f8f1b189aa0.nocache.js"}

where /app2/ is the path to my application.

I'm not sure how the path to the resources are resolved, but I know that the Vaadin directory is supposed to be /app2/VAADIN/* since the widgetsets and other vaadin compiled resources are working just fine and are available when I open the application directly from my browser.
Here are some additional information :

  • Vaadin version : 8.0.5
  • Embedded UI add-on version : 2.0
  • I used ValoTheme for all 3 applications (host and embedded)
  • vaadin.widgetset.mode is set to fetch mode
  • I made sure that CORS is enabled for the applications.

I searched quite a while to resolve this issue but couldn't find enough sources for this particular situation, and I'm also a beginner in both Spring and Vaadin, so I could definitely use some help.


Solution

  • Nice explanation by Morfic! Thanks. And yeah, there was a problem with the add-on. Fixed in 2.1. Please see more info at https://vaadin.com/forum#!/thread/16448312