webtier@glassfish.java.net

Glassfish not compliant with jsf 2.0 spec?

From: <webtier_at_javadesktop.org>
Date: Sat, 27 Feb 2010 12:42:32 PST

First of All, sorry but I couldn't find anyway of formatting the code here.

Now my problem:

According to the section 11.2.6.1 of the JSF 2.0 Spec,

I can override the default ApplicationFactory by specifying this in my faces-config.xml

This is what I have done but my code is NEVER called.

Below is my faces-config.xml

<faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
    <application-factory>
      com.bespokecode.jsf.extensions.CustomApplicationFactory
    </application-factory>

    <action-listener>
      com.bespokecode.jsf.extensions.CustomActionListener
    </action-listener>
</application>

</faces-config>

And this is my CustomApplicationFactory

public class CustomApplicationFactory extends ApplicationFactoryImpl {

   // Log instance for this class
    private static final Logger logger = FacesLogger.APPLICATION.getLogger();

    private volatile Application application;

    public CustomApplicationFactory() {
        super();
        System.out.println("Custom Application constructor called");
    }

    @Override
    public Application getApplication() {
        System.out.println("get Application called");

        if (application == null) {
            application = new CustomApplication();
            if (logger.isLoggable(Level.FINE)) {
                logger.fine(MessageFormat.format("Created Application instance ''{0}''",
                                                 application));
            }
        }
        return application;
    }

}


All I have done in my CustomApplicationFactory is to extend the ApplicationFactoryImpl so I can provide my own Application class. None of the messages in this class gets written anywhere and when I try to retreive the Application class like this

CustomApplication application = (CustomApplication) context.getApplication();

I get a class ClassCastException which says :

java.lang.ClassCastException: com.sun.faces.application.ApplicationImpl cannot be cast to com.bespokecode.jsf.extensions.CustomApplication

AM I doing something wrong or its the mojara code that is not doing it properly?

Just FYI, this is the CustomApplication class, nothing fancy

public class CustomApplication extends ApplicationImpl{

    private SecurityManager securityManager;

    public CustomApplication() {
        super();
    }

    public SecurityManager getSecurityManager() {
        return securityManager;
    }

    public void setSecurityManager(SecurityManager securityManager) {
        this.securityManager = securityManager;
    }
}
[Message sent by forum member 'gcameo' (osbert252003_at_yahoo.com)]

http://forums.java.net/jive/thread.jspa?messageID=389138