Hi Philippe, let me try to shed some light onto the problem:
1) jsf-spring (the library) is nice, but not necessary. Spring's JSF variable resolver is good enough. 2) We used jsf-spring (the library) on a large project, and ran into class-loader issues under Websphere. Use it on your own risk. 3) Spring's included JSF variable resolver is nice - and I use it regularly for resolving spring-beans. I don't use it to inject spring beans int JSF beans, though. I suppose it should work, though, with looking at the code. If you want to dig deeper: ManagedBeanBuilder.initializeProperties should call VariableResolver.resolveVariable and there, your spring-bean should be used. 4) One word of warning: Spring beans will not be able to think in terms of scope - or put otherway, they'll always have a scope of "none" or "application". Manfred was trying to find a solution for this before he went on vacations, maybe he'll come up with something after returning totally refreshed ;). Maybe this is the problem, though. Not sure. 5) You're right - the StartupServletContextListener doesn't have anything to do with the problem. Werner, are you using injection of spring beans into JSF beans? regards, Martin On 4/2/06, Matt Raible <[EMAIL PROTECTED]> wrote: > At first glance, everything looks correct. You could try downloading > Equinox and comparing your configuration. > > https://equinox.dev.java.net/servlets/ProjectDocumentList?folderID=4847 > > There's a pre-built JSF version available - with Spring and Hibernate > on the backend. You'll need a database whose settings match > WEB-INF/classes/jdbc.properties in order to deploy it. > > https://equinox.dev.java.net/files/documents/1901/30019/equinox-jsf.war > > Matt > > On 4/2/06, Philippe Lamote <[EMAIL PROTECTED]> wrote: > > Hi List, > > > > I'm getting unexplainable MyFaces-Spring integration problems, I was > > hoping someone could give a hint. > > > > 1/ First some setup info: I followed the Sping & JSF doc and did this > > to integrate the two: (I will try to be being extensive as big errors > > often small roots...) > > > > 1.1 Libs were added (in web-inf/lib of course; spring.jar & spring- > > web.jar) Tools I use are: Eclipse 3.2, WTP plugin, Tomcat 5.12 and > > Spring 1.2 > > 1.2 web.xml features: > > > > <context-param> > > <param-name>contextConfigLocation</param-name> > > <param-value>/WEB-INF/applicationContext.xml</param-value> > > </context-param> > > <context-param> > > <param-name>log4jConfigLocation</param-name> > > <param-value>/WEB-INF/log4j.properties</param-value> > > </context-param> > > > > <context-param> > > <param-name>javax.faces.CONFIG_FILES</param-name> > > <param-value>/WEB-INF/faces-config.xml</param-value> > > </context-param> > > > > ... and: > > > > <listener> > > <listener- > > class>org.apache.myfaces.webapp.StartupServletContextListener</ > > listener-class> > > </listener> > > > > ... and: > > > > <listener> > > <listener- > > class>org.springframework.web.util.Log4jConfigListener</listener-class> > > </listener> > > > > <listener> > > <listener- > > class>org.springframework.web.context.ContextLoaderListener</listener- > > class> > > </listener> > > > > 1.3 faces-config file features: > > > > <application> > > <variable-resolver> > > org.springframework.web.jsf.DelegatingVariableResolver > > </variable-resolver> > > > > > > <locale-config> > > <default-locale>fr</default-locale> > > <supported-locale>nl</supported-locale> > > <supported-locale>en</supported-locale> > > </locale-config> > > </application> > > .... and an exampe how the JSF Managed beans are declared in this > > faces-config.xml with Spring Managed beans: ("webfacade" is a Spring > > Managed bean, cf Sping config file further) > > > > <managed-bean> > > <managed-bean-name>managerbean</managed-bean-name> > > > > <managed-bean-class>be.mnemonica.web.beans.ManagerBean</managed- > > bean-class> > > <managed-bean-scope>session</managed-bean-scope> > > <managed-property> > > <property-name>facade</property-name> > > <value>#{webfacade}</value> > > </managed-property> > > </managed-bean> > > > > 1.4 Sping applicationContext.xml: (extrait) > > > > <bean id="jdo2Persistor" > > class="be.mnemonica.persistence.JDO2PersistenceDelegator" > > > <property name="modelPackageName"> > > <description> The name of the package where the model > > classes of > > the application reside, for which this Persistence Delegator is > > written) </description> > > <value>be.mnemonica.model</value> > > </property> > > <property name="appMgr"><ref local="appmgr"/></property> > > > > </bean> > > > > <bean id="webfacade" class="be.mnemonica.client.WebFacade"> > > <property name="persistor"> > > <description>The Persistor Delegator for the Facade. > > </description> > > <ref local="jdo2Persistor"/> > > </property> > > </bean> > > > > The idea is: this WebFacade is used by all JSF Managed beans to > > delegate calls to the proper Delegator (e.g. CRUD Model-related calls > > are delegated to the PersistenceDelgatorInterface - I have Sping > > inject this Interface with a JDO2 Implementation implementing this > > Interface. > > > > Just to be explicit: > > I have NOT declared my Spring beans as JSF manage beans (should I?) > > I don't inject any Spring Managed bean with a JSF Managed bean > > > > 2/ Yet, the problems I'm having are substantial. > > The JSF Managed beans just DON'T seem to be injected with > > Sping-"filled" instances (the supposedly injected values are null) > > E.g. in the case above, "modelPackageName" remained "null". > > I could solve some issues by putting in all the JSF Managed beans' > > Constructors: (e.g. in this JSF managerbean) > > ApplicationContext ctx = FacesContextUtils.getWebApplicationContext > > (FacesContext.getCurrentInstance()); > > facade = (WebFacade)ctx.getBean("webfacade"); > > > > Yet of course this is a pity; I'm hardwiring again & creating > > explicit dependancies to Spring. (which is... the opposite of why I > > turned to Spring in the first place!! :-)) > > > > --> Anyone else had issues like this? (or did I forget smth?) > > Or, even if not, any genious idea how to make this work properly? (a > > lesser genius idea that works will be admired as well ;-) > > > > & Just to make sure I get the sequence right, is it correct that > > this is the mechanism: > > By these settings, every time a JSF Managed bean creates a JSF bean, > > Spring intervenes and injects (in cascade) the configured properties. So > > JSF bean creation USES Spring pre-configured Properties. > > Last and least (small sub question) I haven't noticed a difference > > when I leave the MyFaces 's "StartupServletContextListener" in, or > > out the web.xml. --> Is it necessary?! > > > > Thanks, > > Philippe > > > > > > > > > > > > > -- http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces

