Prettyfaces, seamfaces on tomcat fail on startup.

Splash Forums PrettyFaces Users Prettyfaces, seamfaces on tomcat fail on startup.

This topic contains 4 replies, has 2 voices, and was last updated by  loshmi 10 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #17925


    Hello i am using jsf 2, pretty 3.2.1 seam-faces 3.0.1, weld 1.1.0, and tomcat 7.0.11.

    If i use only pretty faces (without seam-faces) everything works. Also if i only use seam-faces (without pretty faces)everything works. But if i use those two together everythings fails on startup. I was looking at the source code and i found this:

    At startup i get this message from weld:

    INFO: Tomcat detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported

    And i guess that is fine because i am in servlet. But then:

    There is a class in seam-faces:

    public class RewriteConfiguration implements ConfigurationProvider {
    public static final String PRETTYFACES_CONFIG_SERVLETCONTEXT_KEY = "";

    public PrettyConfig loadConfiguration(ServletContext sc) {
    WebXmlParser webXmlParser = new WebXmlParser();
    try {
    } 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);

    Which is dependant on the presence of pretty-faces. It tries to get the beanManager from the servlet context under the key know as BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY.But that key is not there, here is why:

    BeanManagerServletContextListener class:

    ‘public class BeanManagerServletContextListener implements ServletContextListener {

    public static final String BEANMANAGER_SERVLETCONTEXT_KEY = “org.jboss.seam.faces.javax.enterprise.spi.BeanManager”;


    private BeanManager beanManager;

    public void contextDestroyed(ServletContextEvent sce) {


    public void contextInitialized(ServletContextEvent sce) {

    sce.getServletContext().setAttribute(BEANMANAGER_SERVLETCONTEXT_KEY, beanManager);



    This class tries to inject beanmanager. But this is a listener so injections don’t work in servlet containers (tomcat). So this class always stores null reference under the key BEANMANAGER_SERVLETCONTEXT_KEY.

    And then somwhere else along the way stuff explodes with null pointer exception trying to obtain a reference to beanmanager.

    I described this on seam forums too here:

    But no body seams to read those forums at all. So i decided to try here :). This is related to pretty faces as well.

    I fixed it like this: I put the BeanManagerServletContextListener in my workspace and i change contextInitialized method into this:

    ‘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);


    So now if the injection fails we try to get the bean manager from the listener. It is a hack, and don’t think it will work on other servlets/cdi implementations but it is a place to start.

    PS. BTW login here is imposiblle with firefox 4. The submit button doesn’t work. :)


    Hi loshmi,

    Thank you for posting this.

    Since it is obviously a bug with the Seam Faces implementation, I think the best way to get a response, and to get it fixed would be to submit the issue to the SEAMFACES JIRA. I have gone ahead and done this for you. It’s good that you already have a solution, but I think that there is probably also a simple solution using the Seam Solder BeanManagerLocator that would remove the need for an implementation-specific solution.

    I’ve gone ahead and submitted this issue for you:

    Thanks for bringing this up, as I’m sure other people will run in to the same problem.



    I will take a look at your login issue :)


    Login works, you just need to refresh the page afterwards… strange.



    Thanks for looking into this. And thanks for creating a ticket.

    And yes, you are right, firefox just need couple of refreshs.


Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.