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
>
>
>
>
>
>

Reply via email to