Skip to main content

Glassfish not compliant with jsf 2.0 spec?

2 replies [Last post]
gcameo
Offline
Joined: 2007-08-22
Points: 0

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

com.bespokecode.jsf.extensions.CustomApplicationFactory

com.bespokecode.jsf.extensions.CustomActionListener

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;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jason Lee

That should be in :


com.bespokecode.jsf.extensions.CustomApplicationFactory

See section 11.4.5 of the spec as well as the XSD in Appendix A.

Hope that helps.

On 2/27/10 2:42 PM, webtier@javadesktop.org wrote:
> 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
>
> > 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">
>
>
> com.bespokecode.jsf.extensions.CustomApplicationFactory
>

>
>
> com.bespokecode.jsf.extensions.CustomActionListener
>

>

>
>

>
> 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@yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389138
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Jason Lee
Senior Member of Technical Staff
GlassFish Administration Console

Oracle Corporation
Phone x31197/+1 405-343-1964
Email jasondlee@sun.com
Blog http://blogs.steeplesoft.com

[att1.html]

gcameo
Offline
Joined: 2007-08-22
Points: 0

Thank you very much. That works perfect.

Kind regards