Hi!

your PageLifeCycle listner is registered twice,
so he is executed twice :)

My guess is that your custom faces-config.xml is parsed twice.
Do you refer to "faces-config.xml" in your web.xml file ?

If so it is parsed twice.

-Matthias

On 11/27/06, A.McCall <[EMAIL PROTECTED]> wrote:

You're right....  I am getting six listeners...
"listeners"= PhaseListener[6]  (id=89)
        [0]= ExtensionsPhaseListener  (id=2387)
        [1]= AutoScrollPhaseListener  (id=2384)
        [2]= PageLifeCycle  (id=2385)
        [3]= ExtensionsPhaseListener  (id=2386)
        [4]= AutoScrollPhaseListener  (id=2388)
        [5]= PageLifeCycle  (id=88)

PageLifeCycle is my custom listener.

I did what you suggested and found that Myfaces and JSF is starting the
listeners..
here is my log:
java.lang.Throwable
        at 
com.rosetta.hcp.pageevents.PageLifeCycle.<init>(PageLifeCycle.java:18)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at
com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:711)
        at
com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:398)
        at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:328)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at 
org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

java.lang.Throwable
        at 
com.rosetta.hcp.pageevents.PageLifeCycle.<init>(PageLifeCycle.java:18)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at
org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:274)
        at
org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:265)
        at
org.apache.myfaces.config.FacesConfigurator.configureLifecycle(FacesConfigurator.java:652)
        at
org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:144)
        at
org.apache.myfaces.webapp.StartupServletContextListener.initFaces(StartupServletContextListener.java:66)
        at
org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:49)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at 
org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)


I think my problem my be that I have jsf and myfaces jars in my lib.
I have both because we have a custom component for a datatable and they need
both jars.
I may need to rewrite custom component to use only MyFaces.
This will be hard since there are objects in JSF and not in MyFaces.
I need to find code in MyFaces for the datatable. Is there any where I can
look to see how to create a custom component thats renders a table in
MyFaces?

Thanks for all your help.




Simon Kitching-3 wrote:
>
> What I was expecting is that you would see two copies of *your* phase
> listener in that list. At the very least, you should see *one*,
> otherwise you wouldn't be getting any callbacks at all!
>
> The phase listeners you list below are normal, and won't be making
> callbacks to your code.
>
> Just FYI, JSF implementations are required to look for all occurrences
> of META-INF/faces-config.xml in the classpath and process them all on
> startup. A faces-config file can provide a list of phase-listeners to be
> regisered on startup; if you look inside the tomahawk jarfile you will
> find a faces-config.xml file that defines these two listeners. To
> repeat, though, these are nothing to do with your problem.
>
> Regards,
>
> Simon
>
> A.McCall wrote:
>> Simon,
>>
>>     I did what you said.  You are absolutely right...I do have 2
>> listeners...
>>      1. org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener
>>      2. org.apache.myfaces.renderkit.html.util.AutoScrollPhaseListener
>>
>> I do not see where these listeners are configured.
>> Do you know how I set it up so I just have one listener?
>>
>> Thanks.
>>
>>
>> Simon Kitching-3 wrote:
>>
>>> A.McCall wrote:
>>>
>>>>   I am having the same problem.  My phaselistener is being called
>>>> twice,
>>>> I
>>>> do not have configs entry in my web.xml, so it's not that.
>>>>
>>>> Just wondering....  Did you ever find out why yours was being called
>>>> twice.
>>>>
>>> Phase listeners work fine for me. I'd be willing to bet that you do have
>>> the phase listener registered twice.
>>>
>>> I suggest that in your phase listener you get the list of registered
>>> listeners then iterate through this and check that there is only one
>>> object whose class is your custom listener class.
>>>
>>> LifecycleFactory factory = (LifecycleFactory)
>>>     FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
>>>
>>> Lifecycle lc =
>>> factory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
>>>
>>> PhaseListener[] listeners = lc.getPhaseListeners();
>>>
>>> If it is registered twice, then you could put a logging statement in
>>> your phase-listener's constructor that prints out the current stack
>>> trace; that will show you where the instances are being created.
>>>
>>> Regards,
>>>
>>> Simon
>>>
>>>
>>>
>>
>>
>
>
>

--
View this message in context: 
http://www.nabble.com/Why-afterPhase%28PhaseEvent-event%29-gets-called-twice-tf288329.html#a7554278
Sent from the MyFaces - Users mailing list archive at Nabble.com.




--
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to