Running two separate Vaadin Servlets in the same application #23088
Replies: 4 comments 3 replies
-
|
Hi, I remember having some similarish "problems" with my recent EntityExplorer project (dev time UI you could drop to your project), but I have forgotten the details there. IIRC I had to workaround with dynamic views only, but the isolation is not that good. I guess version conflicts would be there anyways without OSGi 🤷♂️ Note to myself: update that project for V25. BTW. You might get more eyes by posting to vaadin.com/forum, these GH discussions are in almost no use. I raised your question on our internal Slack channel, let's see if somebody familiar with these internals has some good ideas. |
Beta Was this translation helpful? Give feedback.
-
|
So Which direction would be more intuitive and practical for your situation: Should the
This is bypassing the abstraction. Which components are you referring here? |
Beta Was this translation helpful? Give feedback.
-
|
There are certainly some issues here and it seems shortcuts have been taken over the years when there has only been one implementation of The
When creating There might be a semi-compatible way forward with this by moving the responsibility of creating the context to However, it is good to note that this is likely not the only globality issue you will run into. There are other questions like if each context then needs its own frontend JS bundle or should everything be joined into one? There is no support for creating multiple such ones at the moment and having multiple ones might also cause browser side conflicts - but does this part work properly if you have multiple contexts? |
Beta Was this translation helpful? Give feedback.
-
As already hinted at in another comment, one big fundamental issue might be the Vaadin version since everything is on the same classpath. If the main application requires some specific Vaadin version and your code requires another version, then there's no good way around that. The solution in theory would be that you bundle a custom version of the Vaadin dependencies rewritten to use a separate package name so that the classes can be loaded side-by-side. That would probably lead to some other issues but it would solve the conflicts related to Another big challenge I see is all kinds of global-ish configuration, such as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to provide an isolated UI as part of a Java library for Spring Boot applications. I'm using
vaadin-coredirectly (novaadin-spring) and providing my own implementations and auto-configurations for achieving an isolated, dedicated Servlet for this library, based on Vaadin.However, it seems that it's not possible to do so because of the
VaadinContextinstances that are created on the fly from multiple places instead of configured once and re-used. In a Servlet-based implementation, that means everything is stored in theServletContext, which is shared among all Servlets. So, if my library defines a customLookupimplementation, that will be forced across the entire web application. That's a problem if the end-user application is using Vaadin as well.Even though I provide a custom implementation for
VaadinContextto isolate the data and construct it from my customVaadinService, there are still many components which don't use theVaadinContextinstance built by theVaadinService. Instead, they always build new instances out of the underlyingServletContext. It seems like theVaadinContextis not an actual shared context.Am I missing something or did I understand correctly that it's not possible to use Vaadin for providing isolated UIs as part of a Java library?
Example of what I'm trying to achieve. Say I have a Java library providing OpenAPI support for Spring Boot applications. I would like to serve a UI for the OpenAPI spec as part of the library (built with Vaadin). This UI implementation should be isolated and self-contained so that if the end-user application is also using Vaadin for the actual application frontend, there shouldn't be any conflict. Is that a supported scenario?
Beta Was this translation helpful? Give feedback.
All reactions