You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ken Weiner <kw...@gmail.com> on 2005/11/09 04:36:18 UTC

ApplicationImpl Configuration Problem

I have a custom ApplicationFactory that wraps the original
ApplicationFactory so that it can produce a custom Application that wraps
the original Application. It is configured via faces-config.xml:

<factory>
<application-factory>custom.MyApplicationFactory</application-factory>
</factory>

As a result, the FacesConfigurator class is not able to properly configure
all the standard Converters (for Integer, Long, etc) because it relies on
setting instances of
org.apache.myfaces.config.impl.digester.elements.Converter on the
ApplicationImpl (and my Application is not an instance of ApplicationImpl):

if(application instanceof ApplicationImpl)
{
for (Iterator it = _dispenser.getConverterConfigurationByClassName();
it.hasNext();)
{
String converterClassName = (String) it.next();

((ApplicationImpl)
application).addConverterConfiguration(converterClassName,
_dispenser.getConverterConfiguration(converterClassName));
}
}

Therefore this inner block of code is passed over in my environment. Is
there any way that MyFaces can be changed so that ApplicationImpl does not
need to know about
org.apache.myfaces.config.impl.digester.elements.Converter internally? It
would be nice if the FacesConfigurator could configure any Application
without relying on it being an ApplicationImpl.

Re: ApplicationImpl Configuration Problem

Posted by Ken Weiner <kw...@gmail.com>.
Thanks for the reply, Martin.

I'm not really sure if I understand whether or not they are MyFaces specific
or not. Some seem to be "standard" as they have javax.faces in their ID's
and come from a file called standard-faces.config.xml.

These are the converter ID's for which FacesConfigurator tries to set the
Converter configuration instance:

javax.faces.convert.BooleanConverter
javax.faces.convert.NumberConverter
javax.faces.convert.BigIntegerConverter
javax.faces.convert.DoubleConverter
org.lmb.faces.converter.bool.BooleanConverter
javax.faces.convert.FloatConverter
javax.faces.convert.IntegerConverter
javax.faces.convert.ByteConverter
org.apache.myfaces.convert.StringArrayConverter
org.apache.myfaces.custom.fileupload.UploadedFileConverter
javax.faces.convert.BigDecimalConverter
javax.faces.convert.ShortConverter
javax.faces.convert.CharacterConverter
javax.faces.convert.LongConverter
javax.faces.convert.DateTimeConverter

Since my Application is not an ApplicationImpl, then FacesConfigurator
doesn't inject the configuration into ApplicationImpl and then when
MyApplication delegates to ApplicationImpl, ApplicationImpl throws a
NullPointerException in this code because it has a registered converter but
not the corresponding configuration:

private Converter internalCreateConverter(Class targetClass) {
....
Converter converter = (Converter) converterClass.newInstance();

org.apache.myfaces.config.impl.digester.elements.Converter converterConfig =
(org.apache.myfaces.config.impl.digester.elements.Converter)
_converterClassNameToConfigurationMap.get(converterClass.getName());

Iterator it = converterConfig.getProperties(); <-- a NPE is thrown here
because converterConfig is null
....
}

The result is this stack trace. My application is "SpringApplication":

Caused by: javax.faces.FacesException: Could not instantiate converter:
class javax.faces.convert.IntegerConverter
at org.apache.myfaces.application.ApplicationImpl.internalCreateConverter(
ApplicationImpl.java:556)
at org.apache.myfaces.application.ApplicationImpl.createConverter(
ApplicationImpl.java:494)
at org.lmb.web.jsf.SpringApplication.createConverter(SpringApplication.java
:287)
... 34 more
Caused by: java.lang.NullPointerException
at org.apache.myfaces.application.ApplicationImpl.internalCreateConverter(
ApplicationImpl.java:534)
... 36 more


Does this make sense? Is this a problem, or am I doing something wrong by
writing my own application factory and application and delegating to the
original?

-Ken

On 11/9/05, Martin Marinschek <ma...@gmail.com> wrote:
>
> But this is just additional, MyFaces specific configuration, right?
>
> The converters get added alright, they are just not processing
> additional stuff in the faces-config file that would be special to
> MyFaces?
>
> regards,
>
> Martin
>
> On 11/9/05, Ken Weiner <kw...@gmail.com> wrote:
> > I have a custom ApplicationFactory that wraps the original
> > ApplicationFactory so that it can produce a custom Application that
> wraps
> > the original Application. It is configured via faces-config.xml:
> >
> > <factory>
> > <application-factory>custom.MyApplicationFactory</application-factory>
> > </factory>
> >
> > As a result, the FacesConfigurator class is not able to properly
> configure
> > all the standard Converters (for Integer, Long, etc) because it relies
> on
> > setting instances of
> > org.apache.myfaces.config.impl.digester.elements.Converter
> > on the ApplicationImpl (and my Application is not an instance of
> > ApplicationImpl):
> >
> > if(application instanceof ApplicationImpl)
> > {
> > for (Iterator it =
> > _dispenser.getConverterConfigurationByClassName();
> > it.hasNext();)
> > {
> > String converterClassName = (String) it.next();
> >
> > ((ApplicationImpl)
> > application).addConverterConfiguration(converterClassName,
> >
> > _dispenser.getConverterConfiguration(converterClassName));
> > }
> > }
> >
> > Therefore this inner block of code is passed over in my environment. Is
> > there any way that MyFaces can be changed so that ApplicationImpl does
> not
> > need to know about
> > org.apache.myfaces.config.impl.digester.elements.Converter
> > internally? It would be nice if the FacesConfigurator could configure
> any
> > Application without relying on it being an ApplicationImpl.
> >
> >
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>

Re: ApplicationImpl Configuration Problem

Posted by Martin Marinschek <ma...@gmail.com>.
But this is just additional, MyFaces specific configuration, right?

The converters get added alright, they are just not processing
additional stuff in the faces-config file that would be special to
MyFaces?

regards,

Martin

On 11/9/05, Ken Weiner <kw...@gmail.com> wrote:
> I have a custom ApplicationFactory that wraps the original
> ApplicationFactory so that it can produce a custom Application that wraps
> the original Application.  It is configured via faces-config.xml:
>
>  <factory>
>      <application-factory>custom.MyApplicationFactory</application-factory>
>  </factory>
>
>  As a result, the FacesConfigurator class is not able to properly configure
> all the standard Converters (for Integer, Long, etc) because it relies on
> setting instances of
> org.apache.myfaces.config.impl.digester.elements.Converter
> on the ApplicationImpl (and my Application is not an instance of
> ApplicationImpl):
>
>  if(application instanceof ApplicationImpl)
>  {
>      for (Iterator it =
> _dispenser.getConverterConfigurationByClassName();
> it.hasNext();)
>      {
>          String converterClassName = (String) it.next();
>
>          ((ApplicationImpl)
> application).addConverterConfiguration(converterClassName,
>
> _dispenser.getConverterConfiguration(converterClassName));
>      }
>  }
>
>  Therefore this inner block of code is passed over in my environment.  Is
> there any way that MyFaces can be changed so that ApplicationImpl does not
> need to know about
> org.apache.myfaces.config.impl.digester.elements.Converter
> internally?  It would be nice if the FacesConfigurator could configure any
> Application without relying on it being an ApplicationImpl.
>
>
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces