Thanks for the add-on. I’m running into issues, and time permitting I’ll try to debug them or at least put together test cases to help address them. In the mean time, here’s what I’m hitting.
I’ve been trying to use it in JBoss AS 7.1.1.Final, and have run into a few hiccups that’re preventing me from getting far.
I replaced my custom CDI-enabled Vaadin servlet with yours and altered my Vaadin app class to extend AbstractCdiApplication, then redeployed. The deployment succeeded, but access to the application immediately failed with a somewhat inscrutable error “java.lang.NoClassDefFoundError: org/jboss/weld/util/reflection/Formats$6” (see below) that almost seems internal to Weld, but didn’t occur without the cdi utils extension. I’m looking at putting together a self-contained test case, as the code in question is a bit big to paste.
Before deployment I’d tried to change my @SessionScoped components to @VaadinScoped(VaadinScope.APPLICATION), but found that deployment would then fail with errors about circular dependencies: “WELD-001443 Pseudo scoped bean has circular dependencies”. It appears that CDI wasn’t recognising the @VaadinScoped annotation as a valid scope (or it’s a pseudo-scope) and wasn’t able to inject proxied instances to handle circular dependencies, so it was failing. See https://issues.jboss.org/browse/WELD-1152 .
I worked around that by decoupling the circular dependency via CDI events ( @Inject Event and @Observes ), which is a bit cleaner anyway. I’m not convinced the VaadinScope is actually doing what it’s meant to, though.
During testing, I noticed that AbstractCdiApplication isn’t proxyable because it has final methods. While it’s a real PITA that CDI can’t proxy final methods, until/unless the JVM is fixed that’s the case, so final methods should be avoided for classes that might need to be proxied. Since the Vaadin application may well need to be proxied to be injected into components that need to reference it, this should probably be fixed.
Anyhow, I can’t seem to get it working, so roll back to my custom CDI-enabled Vaadin servlet and to using @SessionScoped beans. Since the CDI utils have a 1:1 session-to-application mapping this isn’t really very different to @VaadinScoped(APPLICATION). I’ll be interested in testing out any ideas you have and, time permitting, will see if I can produce a test case for the below:
exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/jboss/weld/util/reflection/Formats$6
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:1010)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:548)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
root cause
java.lang.NoClassDefFoundError: org/jboss/weld/util/reflection/Formats$6
org.jboss.weld.util.reflection.Formats.formatAsFormalParameterList(Formats.java:137)
org.jboss.weld.introspector.jlr.WeldMethodImpl.toString(WeldMethodImpl.java:183)
org.jboss.weld.exceptions.WeldExceptionKeyMessage.<init>(WeldExceptionKeyMessage.java:55)
org.jboss.weld.exceptions.WeldException.<init>(WeldException.java:65)
org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:518)
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174)
org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:291)
org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:681)
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:118)
org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703)
org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712)
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161)
org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157)
org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131)
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153)
org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:290)
org.vaadin.virkki.cdiutils.application.VaadinContext$VaadinContextImpl.doGet(VaadinContext.java:86)
org.vaadin.virkki.cdiutils.application.VaadinContext$VaadinContextImpl.get(VaadinContext.java:74)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:643)
org.vaadin.virkki.cdiutils.application.AbstractCdiApplicationServlet.getNewApplication(AbstractCdiApplicationServlet.java:43)
org.vaadin.virkki.cdiutils.application.AbstractCdiApplicationServlet.getNewApplication(AbstractCdiApplicationServlet.java:1)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:984)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:807)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:456)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)