Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when two CDI UIs are deployed in separate WARs inside of an EAR #97

Closed
vaadin-bot opened this issue Apr 2, 2014 · 7 comments

Comments

@vaadin-bot
Copy link

Originally by @vaadin-kim


Bundling two WAR's both containing a @CDIUI into an EAR and deploying it on Glassfish/JBoss will result in an exception:

2014-04-02T14:29:55.600+0300|SEVERE: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type com.vaadin.cdi.UIScoped

Test case attached.


Imported from https://dev.vaadin.com/ issue #13526

@vaadin-bot
Copy link
Author

Originally by @vaadin-kim


Attachment added: example.zip (21.9 KiB)

@vaadin-bot
Copy link
Author

Originally by @zch


The example project needs to add an empty META-INF/beans.xml to the WAR packages, which gets us a bit further with one of the UIs working correctly, but the second one (in the second WAR) will fail with the exception java.lang.IllegalStateException: CDI listener identified, but there is no active UI available.

This is due to the way Extensions are implemented in CDI. Extensions are always loaded in the scope of the EAR, so they will only be applied once, which means that you can only register a scope (@UIScope is the relevant issue here) once for the entire EAR, which means that whenever you try to find objects from the UIScope, you'll call into the scope of one single WAR, no matter from where you initiate the access. This means that CDI for vaadin apps will only work reliably in one single WAR inside an EAR.

@mrts
Copy link

mrts commented May 1, 2018

There was hope that two Vaadin 8 CDI UIs may work in WildFly versions 14 and 15 that use Weld 3.0.5.Final or greater where https://issues.jboss.org/browse/WELD-2143 and https://issues.jboss.org/browse/WELD-2250 are fixed, but when I tested with an EAR that contained two CDI UI WARs, the deployment failed with error

Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
[CDIUI_SCOPE] Inconsistent deployment: The CDI UI class com.example.SecondUI should be @UIScoped.
	at com.vaadin.cdi.internal.VaadinExtension.throwInconsistentDeployment(VaadinExtension.java:93)
	at com.vaadin.cdi.internal.VaadinExtension.processManagedBean(VaadinExtension.java:86)
	at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

SecondUI actually had @CDIUI annotation and worked stand-alone, so this seems to indicate that the problem is still there.

There is a minimal project to reproduce the error here:

https://gitlab.com/mrts/two-vaadin-cdi-uis-in-one-ear

@mrts
Copy link

mrts commented Nov 23, 2018

Great news - multiple WARs now work in a single EAR with Vaadin 12 CDI, at least in WildFly 14.

Here's a sample project to try this out:

https://gitlab.com/mrts/vaadin12-javaee-multiple-wars-in-one-ear

@peholmst
Copy link
Member

peholmst commented Mar 5, 2019

@mrts Please check #282

@mrts
Copy link

mrts commented Mar 7, 2019

@peholmst Thank you, I will when time allows!

@mrts
Copy link

mrts commented Mar 8, 2019

@peholmst Thank you, I confirm that this fixes the problem in the test application that I created. Let's see if we run into problems in a larger real life application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants