You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "A.McCall" <am...@rosettatg.com> on 2006/11/26 16:13:42 UTC

Re: Why afterPhase(PhaseEvent event) gets called twice

Hi,

  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.

thanks.


Saul Qunming Yuan wrote:
> 
> Yes, I have a getPhaseId() which returns PhaseId.RENDER_RESPONSE, and the 
> log info prints out twice in my afterPhase method.
> 
> ----- Original Message ----- 
> From: "hicham abassi" <ha...@gmail.com>
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Sent: Sunday, September 11, 2005 3:10 AM
> Subject: Re: Why afterPhase(PhaseEvent event) gets called twice
> 
> 
>> Try to return a PhaseID constant value into getPhaseId() of your
>> Listener.
>> Do that for each Phase, and check if you have twice call into afterPhase.
>> A simple logger into beforePhase and afterPhase can do the job.
>>
>>
>>
>> 2005/9/10, Saul Qunming Yuan <yu...@dataanvil.com>:
>>> Yes, I rebuilt my application and cleaned out the work-directory. When I
>>> start tomcat, I see phase listener registered only once:
>>>
>>> DEBUG com.sun.faces.lifecycle.LifecycleImpl -
>>> addPhaseListener(RENDER_RESPONSE(6),com.tss.testadmin.listener.ViewPhaseListener@2e6c66
>>>
>>> thanks,
>>>
>>> Saul
>>>
>>> ----- Original Message -----
>>> From: "Martin Marinschek" <ma...@gmail.com>
>>> To: "MyFaces Discussion" <us...@myfaces.apache.org>
>>> Sent: Friday, September 09, 2005 5:13 AM
>>> Subject: Re: Why afterPhase(PhaseEvent event) gets called twice
>>>
>>>
>>> > Sure you cleaned out your application, work-directory, etc.?
>>> >
>>> > this clearly is the problem if the PhaseListener is called twice!
>>> >
>>> > regards,
>>> >
>>> > Martin
>>> >
>>> > On 9/9/05, Saul Qunming Yuan <yu...@dataanvil.com> wrote:
>>> >> Thanks for your response. Yes, I have javax.faces.CONFIG_FILES and
>>> >> faces-config.xml defined in web.xml, I removed that part from
>>> web.xml,
>>> >> but
>>> >> still get the same problem. Any ideas?
>>> >>
>>> >> thanks.
>>> >>
>>> >> ----- Original Message -----
>>> >> From: "Jan Bols" <ja...@ivpv.ugent.be>
>>> >> To: "MyFaces Discussion" <us...@myfaces.apache.org>
>>> >> Sent: Thursday, September 08, 2005 2:32 AM
>>> >> Subject: Re: Why afterPhase(PhaseEvent event) gets called twice
>>> >>
>>> >>
>>> >> > Perhaps, this comes from the fact that you specify
>>> >> >
>>> >> >     <context-param>
>>> >> >         <param-name>javax.faces.CONFIG_FILES</param-name>
>>> >> >         <param-value>/WEB-INF/faces-config.xml</param-value>
>>> >> >     </context-param>
>>> >> >
>>> >> > in your web.xml file. The javax.faces.CONFIG_FILES variable is set 
>>> >> > to
>>> >> > /WEB-INF/faces-config.xml by default and specifying it again in 
>>> >> > web.xml
>>> >> > makes the faces-config.xml file to be processed twice (for some 
>>> >> > raeson
>>> >> > I
>>> >> > don't know). This results in your registered phaseListener to 
>>> >> > actually
>>> >> > be
>>> >> > registered twice as well.
>>> >> >
>>> >> > The solution is to delete this part in your web.xml or to rename
>>> >> > faces_config.xml to something else.
>>> >> >
>>> >> > Jan
>>> >> >
>>> >> > On Thu, 08 Sep 2005 03:25:38 +0200, Saul Qunming Yuan
>>> >> > <yu...@dataanvil.com>
>>> >> > wrote:
>>> >> >
>>> >> >> Hi,
>>> >> >>
>>> >> >> I implemented a phaseListener to catch phase event. However, every
>>> >> >> time
>>> >> >> a jsp page rendered from a backing bean, the afterPhase(PhaseEvent
>>> >> >> event) method gets called twice, and I get the same viewId by 
>>> >> >> calling
>>> >> >> facesContext.getViewRoot().getViewId(). Any ideas what the problem 
>>> >> >> is?
>>> >> >>
>>> >> >> thanks,
>>> >> >> Saul
>>> >> >>
>>> >> >>
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> >
>>> > http://www.irian.at
>>> > Your JSF powerhouse -
>>> > JSF Trainings in English and German
>>>
>>>
>>
>>
>> -- 
>>
>> hicham ABASSI
>> habassi@gmail.com 
> 
> 
> 

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


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by Matthias Wessendorf <ma...@apache.org>.
Hi,

is the "com.sun.faces.util.Util" part of their -impl JAR file?
If so it is general bad to code against impl stuff.

Since the RI is open source, just go ahead and *copy* the code over to
your custom java code. Not a big deal. You can code against that *new*
util clazz
(not sure how many dependencies that guy has to other sun ri internal clazzes)

-Matthias

On 11/27/06, A.McCall <am...@rosettatg.com> wrote:
>
> Simon,
>
>    Can you point me to where I can find source code for MyFaces?
>    I am really having a hard time trying to re-create my custom component in
> MyFaces.
>    My first problem is that I can't find the compatible library for
> com.sun.faces.util.Util in MyFaces.
>
> Thanks.
>
>
> Simon Kitching-3 wrote:
> >
> > Yep, having both the Sun and Myfaces implementations in the classpath is
> > likely to cause all sorts of problems. The Sun "ConfigureListener" is
> > there in the stack trace; I would guess that it is searching for all
> > META-INF/faces-config.xml files and processing them, and so is MyFaces,
> > thus adding every phase listener twice.
> >
> > There are no objects "in JSF" that are not in MyFaces; the MyFaces
> > "core" library is a 100% feature-complete implementation of the JSF 1.1
> > specification.
> >
> > If you want to see how to write a custom table implementation, you could
> > look at the source for the MyFaces Tomahawk library; it includes a
> > custom table. Before doing this, though, are you quite sure you do need
> > to write a custom table? The tomahawk table is pretty flexible...
> >
> > Regards,
> >
> > Simon
> >
> >
> > A.McCall 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
> >>
> >> 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#a7554497
> 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

Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by Matthias Wessendorf <ma...@apache.org>.
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 <am...@rosettatg.com> 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

Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by "A.McCall" <am...@rosettatg.com>.
Simon,

   Can you point me to where I can find source code for MyFaces?
   I am really having a hard time trying to re-create my custom component in
MyFaces.
   My first problem is that I can't find the compatible library for
com.sun.faces.util.Util in MyFaces.
   
Thanks.


Simon Kitching-3 wrote:
> 
> Yep, having both the Sun and Myfaces implementations in the classpath is 
> likely to cause all sorts of problems. The Sun "ConfigureListener" is 
> there in the stack trace; I would guess that it is searching for all 
> META-INF/faces-config.xml files and processing them, and so is MyFaces, 
> thus adding every phase listener twice.
> 
> There are no objects "in JSF" that are not in MyFaces; the MyFaces 
> "core" library is a 100% feature-complete implementation of the JSF 1.1 
> specification.
> 
> If you want to see how to write a custom table implementation, you could 
> look at the source for the MyFaces Tomahawk library; it includes a 
> custom table. Before doing this, though, are you quite sure you do need 
> to write a custom table? The tomahawk table is pretty flexible...
> 
> Regards,
> 
> Simon
> 
> 
> A.McCall 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
>>
>> 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#a7554497
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by Simon Kitching <si...@rhe.co.nz>.
Yep, having both the Sun and Myfaces implementations in the classpath is 
likely to cause all sorts of problems. The Sun "ConfigureListener" is 
there in the stack trace; I would guess that it is searching for all 
META-INF/faces-config.xml files and processing them, and so is MyFaces, 
thus adding every phase listener twice.

There are no objects "in JSF" that are not in MyFaces; the MyFaces 
"core" library is a 100% feature-complete implementation of the JSF 1.1 
specification.

If you want to see how to write a custom table implementation, you could 
look at the source for the MyFaces Tomahawk library; it includes a 
custom table. Before doing this, though, are you quite sure you do need 
to write a custom table? The tomahawk table is pretty flexible...

Regards,

Simon


A.McCall 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
>
> 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
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>>
>>     
>
>   


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by "A.McCall" <am...@rosettatg.com>.
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.


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by Simon Kitching <si...@rhe.co.nz>.
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
>>
>>
>>     
>
>   


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by "A.McCall" <am...@rosettatg.com>.
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#a7553191
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Why afterPhase(PhaseEvent event) gets called twice

Posted by Simon Kitching <si...@rhe.co.nz>.
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