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

com.vaadin.cdi.internal.CDIUtil#lookupBeanManager cannot find BeanManager in jetty #179

Open
maxusoltsev opened this issue Oct 21, 2016 · 4 comments

Comments

@maxusoltsev
Copy link

Hello !
When using jetty-maven-plugin 9.3.9.v20160517 and vaadin-cdi 1.0.3, UIs annnotated as @CDIUI does not work, i think becouse jetty does not expose BeasManager as "java:comp/BeanManager", "java:comp/env/BeanManager" jndi names, so com.vaadin.cdi.internal.CDIUtil#lookupBeanManager returns null (but @Inject works).
It can be resolved by using CDI.current().getBeanManager() (and it works) instead of lookup, but javax.enterprise.inject.spi.CDI is availible only in javaee 7 api (CDI 1.1), and vaadin-cdi uses javaee-api 6.
I resolved this issue locally by overriding com.vaadin.cdi.CDIUIProvider , VaadinCDIServlet, etc, but maybe there is some simpler way ?
Thank you.

@chergey
Copy link

chergey commented Feb 27, 2017

Could you post your solution?

@maxusoltsev
Copy link
Author

Please take a look on https://github.com/maxusoltsev/vaadin-jetty-cdi

@chergey
Copy link

chergey commented Feb 27, 2017

Thank you a lot.

@gotzl
Copy link

gotzl commented May 1, 2017

In case s.o. is interested, I've used s.t. like this:

public class MyExtension implements Extension { void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) { try { InitialContext ic = new InitialContext(); ic.bind("java:comp/BeanManager", bm); } catch (NamingException e1) { } try { InitialContext ic = new InitialContext(); ic.bind("java:comp/env/BeanManager", bm); } catch (NamingException e1) { } } }
and a file META-INF/services/javax.enterprise.inject.spi.Extension advertising the extension...

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

No branches or pull requests

3 participants