At a first glance this looks valid. The fact that it does not work makes me want to look deeper into the issue, looks like a possible bug.
Spring beans from the web context can be made available via @Produces @SpringBean, but I understand that this is exactly the part that does not work. I plan on providing automatic auto-importing, auto-vetoing for Spring beans coming from a web context (i.e. skipping the @Produces @SpringBean part) but that is still WIP, as a more elaborate solution is required due to Servlet and CDI container lifecycle issues.
May be this will help.
In web.xml I use standard configuration for spring initialization:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/applicationContext*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
and WEB-INF/spring contains three app files:
and use SpringCdiProducer as mentioned above.
Now I use injected ApplicationContext and it works ok. Thanks to this module now I can use Spring from CDI directly without touching FacesContext (FacesContextUtils.getWebApplicationContext(..)). This helps for unit testing business logics very much.
Thanks for the update and the interest in the Seam Spring module.
I haven't been able to reproduce this issue so I created a basic example from our JBoss AS7 Spring archetype and added the Seam Spring module on top of it as a simple example of how this should work.
You can find it here: https://github.com/mbogoevici/Seam-Spring-Basic-Example (use the 'glassfish' branch).
You can see the CDI extension working when invoking the SimpleServlet (via $URL/servlet?user=jdoe), as classes in the org.jboss.seam.spring.example.cdi package are all CDI beans (reusing the Spring configured UserDao).
I hope that this helps moving the discussion forward, please take a look and maybe you can spot the difference between your case and this.
Please let me know how that worked.
if you happen to have worked on this improvement, i would really be insterested :
. I plan on providing automatic auto-importing, auto-vetoing for Spring beans coming from a web context (i.e. skipping the @Produces @SpringBean part) but that is still WIP, as a more elaborate solution is required due to Servlet and CDI container lifecycle issues.
BTW what does WIP means ?