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





Reply via email to