PDA

View Full Version : problem in configuring jsf with Spring 2.0


mnrz57
Jul 9th, 2006, 03:52 AM
hi all
I have a simple JSF application and now I want to integrate this with JSF.
I probe all the Internet and I did everything rightly but the my Spring bean not recognized by JSF. my configuration files are below:
------
web.xml

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServl et
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
-----
faces-config.xml

<application>
<!-- org.springframework.web.jsf.VariableResolverImpl-->
<variable-resolver>org.springframework.web.jsf.DelegatingVariableReso lver</variable-resolver>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
</application>

<managed-bean>
<description>displays a grid regarding to user input number</description>
<managed-bean-name>numControls</managed-bean-name>
<managed-bean-class>com.hellojsf.bean.NumControls</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>numService</property-name>
<value>#{numService}</value>
</managed-property>
</managed-bean>
------
applicationContext.xml

<beans>

<!-- this element causes spring to configure the
AnnotationBeanConfigurer aspect in spring-aspects.jar
so that it has a reference to the bean factory
-->
<aop:spring-configured/>


<!-- service used by the Account bean -->
<bean id="numService"
class="com.hellojsf.service.impl.NumServiceImpl" singleton="false" >
</bean>

</beans>

-----------
Face Backing bean

public class NumControls {
private int numOfControls = 0;
private HtmlPanelGrid controlPanel;
private HtmlOutputText out;
private NumService numService; //(an interface) this is that weird spring bean. :(

//getters and setters....

.....
}
-----------
when I run the application it throws a NullPointerException when calling the action method that using the spring bean.

please help me out, this really confused me :confused:

regards
mohammad