-
1. Re: Seam-faces with tomcat
bleathem Apr 20, 2011 1:42 AM (in response to piklos)Seam Faces 3.0.1 is now available in the maven repositories - sorry for the delay.
What you describe does indeed sound odd. Can you please file a jira issue, and attach a simple example demonstrating the failing behaviour you describe?
-
2. Re: Seam-faces with tomcat
piklos Apr 20, 2011 4:21 AM (in response to piklos)Jirra issue
I hope its clear enough. -
3. Re: Seam-faces with tomcat
piklos Apr 20, 2011 7:19 AM (in response to piklos)The problem is still there even with 3.0.1-Final version.
-
4. Re: Seam-faces with tomcat
fup Apr 28, 2011 3:04 PM (in response to piklos)Testing the example attached to the Jira issue I get the following exception (before getting a BeanManagerUnavailableException):
org.jboss.weld.exceptions.DefinitionException: WELD-000072 Managed bean declaring a passivating scope must be passivation capable.
Passivating scopes (e.g. session or conversation) require managed beans to implement Serializable. If I implement the interface for the one and only bean in the example, the application starts fine. Application and request scopes worked all along, since they aren't passivating scopes.
(I guess, the issue was not Tomcat related.)
-
5. Re: Seam-faces with tomcat
piklos Apr 29, 2011 9:39 AM (in response to piklos)Yes you are right. It was my mistake after all. The bug can probably be closed.
However i found something different that i hope somebody can help me with.
When i depoy my application to servlet in one point it says
INFO: Tomcat detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supportedBut the seam faces listener:
public class BeanManagerServletContextListener implements ServletContextListener { public static final String BEANMANAGER_SERVLETCONTEXT_KEY = "org.jboss.seam.faces.javax.enterprise.spi.BeanManager"; @Inject private BeanManager beanManager; public void contextDestroyed(ServletContextEvent sce) { } public void contextInitialized(ServletContextEvent sce) { sce.getServletContext().setAttribute(BEANMANAGER_SERVLETCONTEXT_KEY, beanManager); } }
Tries to inject BeanManager there and to put it into the servlet context with accesible via key. That bean manager is always null, i am guessing that that is so because injection doesn't work with listeners, as stated above.
Now when you have PrettyFaces filter in your web.xml. While beaing initilized that filter calls loadConfiguration method on a RewriteConfiguration class.
That class looks like this on seam-faces 3.0.1
@Requires("com.ocpsoft.pretty.faces.spi.ConfigurationProvider") public class RewriteConfiguration implements ConfigurationProvider { public static final String PRETTYFACES_CONFIG_SERVLETCONTEXT_KEY = "org.jboss.seam.faces.com.ocpsoft.pretty.faces.spi.ConfigurationProvider"; @Override public PrettyConfig loadConfiguration(ServletContext sc) { WebXmlParser webXmlParser = new WebXmlParser(); try { webXmlParser.parse(sc); } catch (IOException ex) { throw new RuntimeException(ex); } catch (SAXException ex) { throw new RuntimeException(ex); } BeanManager beanManager = (BeanManager) sc.getAttribute(BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY); ViewConfigStore store = BeanManagerUtils.getContextualInstance(beanManager, ViewConfigStore.class); ... ...
However since bean manager is always null in the servlet context this class always explodes with null pointer exception. Apperently this class works only when com.ocpsoft.pretty.faces.spi.ConfigurationProvider is present, which is my case.
Do i need to add seam servlet?? Or what? -
6. Re: Seam-faces with tomcat
piklos Apr 29, 2011 10:04 AM (in response to piklos)I changed
public class BeanManagerServletContextListener implements ServletContextListener { public static final String BEANMANAGER_SERVLETCONTEXT_KEY = "org.jboss.seam.faces.javax.enterprise.spi.BeanManager"; @Inject private BeanManager beanManager; public void contextDestroyed(ServletContextEvent sce) { } public void contextInitialized(ServletContextEvent sce) { if (beanManager == null){ String name = Listener.class.getPackage().getName() + "." + BeanManager.class.getName(); beanManager = (BeanManager)sce.getServletContext().getAttribute(name); } sce.getServletContext().setAttribute(BEANMANAGER_SERVLETCONTEXT_KEY, beanManager); } }
Now although the injection is always null the bean manager is found in the servlet context.