Re:Problemas com Spring e JSF

posta ae:

1- tua estrutua de diretorios do WEB-INF
2- web.xml

bom dia galera.

To tendo a falha abaixo com a integracao entre JSF e Spring,

Alguem tem como nos ajudar?

2007-04-18 10:10:14,051 ERROR [main ] (ContextLoader.java:205) Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘articleHandler’ defined in URL [file:/C:/Documents%20and%20Settings/f0fp083/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/webapps/EDIWebJSF/WEB-INF/classes/applicationContext-jsf.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy5] to required type [br.com.teste.logic.command.masterdata.service.MasterdataService] for property ‘masterdataService’; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy5] to required type [br.com.teste.logic.command.masterdata.service.MasterdataService] for property ‘masterdataService’: no matching editors or conversion strategy found
Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy5] to required type [br.com.teste.logic.command.masterdata.service.MasterdataService] for property ‘masterdataService’; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy5] to required type [br.com.teste.logic.command.masterdata.service.MasterdataService] for property ‘masterdataService’: no matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy5] to required type [br.com.teste.logic.command.masterdata.service.MasterdataService] for property ‘masterdataService’: no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:224)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:139)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:772)

Os arquivos de configuracao estao abaixo. ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

	<!-- ========================= GENERAL DEFINITIONS ========================= -->

	<bean id="messageSource"
		class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basenames">
			<list>
				<value>
					com.teste.ui.resource.projeto_messages
				</value>
				<value>
					com.teste.ui.resource.security_messages
				</value>
			</list>
		</property>
	</bean>

	<!-- ========================= Start of SERVICE DEFINITIONS ========================= -->
	<bean id="loginHandler"
		class="com.teste.ui.security.SimpleLoginHandler" />

	<bean id="masterdataService"
		class="com.teste.logic.command.masterdata.service.MasterdataService" />

	<bean id="articleHandler"
		class="com.teste.ui.artikeldaten.ArticleManager">
		<property name="masterdataService">
			<ref bean="masterdataService" />
		</property>
	</bean>
	<!-- ========================= End of SERVICE DEFINITIONS ========================= -->

</beans>

e o arquivo faces-config.xml

Abaixo o arquivo faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
	<!-- Supported locales are german and english -->
	<application>
		<!-- <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> -->
		<view-handler>org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl</view-handler>
		<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
		<locale-config>
			<default-locale>en</default-locale>

		</locale-config>		
		<message-bundle>com.teste.ui.resource.test_messages</message-bundle>
	</application>
</faces-config>

Ola.

Segue o web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
  <description>Test Application</description>

  <!-- Spring Context Config -->	
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <!-- Hibernate Session Filter -->  
  <filter>
  	<description>Hibernate Open Session In View Filter</description>
  	<filter-name>hibernateFilter</filter-name>
  	<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  </filter>
  
  <!-- Ajax4Jsf Config -->
  <context-param> 
  	<param-name>org.ajax4jsf.SKIN</param-name> 
  	<param-value>blueSky</param-value> 
  </context-param> 
  
  <filter> 
  	<display-name>Ajax4jsf Filter</display-name> 
  	<filter-name>ajax4jsf</filter-name> 
  	<filter-class>org.ajax4jsf.Filter</filter-class> 
  </filter>   
  
  <filter-mapping> 
  <filter-name>ajax4jsf</filter-name> 
	<servlet-name>Faces Servlet</servlet-name>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>INCLUDE</dispatcher>
  </filter-mapping>  
  
  <!-- Spring Config -->
  <context-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.web.context.support.XmlWebApplicationContext</param-value>
  </context-param>

  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:applicationContext.xml
            classpath*:applicationContext-localDataSource.xml
            classpath*:applicationContext-jsf.xml
            classpath*:applicationContext-service.xml
            classpath*:applicationContext-jsf-security.xml
        </param-value>
  </context-param>
  
   <filter>
        <filter-name>Acegi Filter Chain Proxy</filter-name>
        <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
        <init-param>
            <param-name>targetClass</param-name>
            <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
        </init-param>
    </filter>

    <filter-mapping>
      <filter-name>Acegi Filter Chain Proxy</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>REQUEST</dispatcher>      
    </filter-mapping>  
    
  <!-- Tiles Config -->
  <context-param>
        <param-name>tiles-definitions</param-name>
        <param-value>/WEB-INF/tiles-config.xml</param-value>
  </context-param>
    
  <!-- JSF 1.1 Standard Config -->
  <context-param>
    <description>Comma separated list of URIs of (additional) faces config files.
            (e.g. /WEB-INF/my-config.xml)
            See JSF 1.0 PRD2, 10.3.2
            Attention: You do not need to put /WEB-INF/faces-config.xml in here.
    </description>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
  </context-param>
  
  <!-- MyFaces 1.1 Config -->  
  <context-param>
    <description>State saving method: "client" or "server" (= default)
            See JSF Specification 2.5.3</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default).
            Defines the amount (default = 20) of the latest views are stored in session.</description>
    <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
    <param-value>20</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default).
            If true (default) the state will be serialized to a byte stream before it 
            is written to the session.
            If false the state will not be serialized to a byte stream.</description>
    <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default) and if 
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
            If true (default) the serialized state will be compressed before it 
            is written to the session. If false the state will not be compressed.</description>
    <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>This parameter tells MyFaces if javascript code should be allowed in the
            rendered HTML output.
            If javascript is allowed, command_link anchors will have javascript code
            that submits the corresponding form.
            If javascript is not allowed, the state saving info and nested parameters
            will be added as url parameters.
            Default: "true"</description>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <description>If true, rendered HTML code will be formatted, so that it is "human readable".
            i.e. additional line separators and whitespace will be written, that do not
            influence the HTML code.
            Default: "true"</description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>If true, a javascript function will be rendered that is able to restore the
            former vertical scroll on every request. Convenient feature if you have pages
            with long lists and you do not want the browser page to always jump to the top
            if you trigger a link or button action that stays on the same page.
            Default: "false"</description>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
  </context-param>

  <context-param>
	<description>Validate managed beans and navigation rules.</description>
    <param-name>org.apache.myfaces.validate</param-name>
    <param-value>true</param-value>
  </context-param>

<!--
  <context-param>
    <description>A class implementing the
		    org.apache.myfaces.shared.renderkit.html.util.AddResource
		    interface. It is responsible to
   			place scripts and css on the right position in your HTML document.
            Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"</description>
    <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
    <param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
  </context-param>
-->
  
  <!-- MyFaces Tomahawk Config -->
  <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
      <description>Set the size limit for uploaded files.
                Format: 10 - 10 bytes
                        10k - 10 KB
                        10m - 10 MB
                        1g - 1 GB</description>
      <param-name>uploadMaxFileSize</param-name>
      <param-value>100m</param-value>
    </init-param>
    <init-param>
      <description>Set the threshold size - files
                    below this limit are stored in memory, files above
                    this limit are stored on disk.

                Format: 10 - 10 bytes
                        10k - 10 KB
                        10m - 10 MB
                        1g - 1 GB</description>
      <param-name>uploadThresholdSize</param-name>
      <param-value>100k</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/faces/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>SourceCodeServlet</servlet-name>
    <servlet-class>org.apache.myfaces.shared_tomahawk.util.servlet.SourceCodeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>SourceCodeServlet</servlet-name>
    <url-pattern>*.source</url-pattern>
  </servlet-mapping>
  
  <!-- Standard config -->
  <session-config>
  	<session-timeout>5</session-timeout>
  </session-config>
  
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  
  <error-page>
	<error-code>500</error-code>
	<location>/error.jsf</location>
  </error-page>
</web-app>

Este arquivo esta dentro da pasta projeto/webcontent/web-inf

Ola.

Segue o web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
  <description>Test Application</description>

  <!-- Spring Context Config -->	
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <!-- Hibernate Session Filter -->  
  <filter>
  	<description>Hibernate Open Session In View Filter</description>
  	<filter-name>hibernateFilter</filter-name>
  	<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  </filter>
  
  <!-- Ajax4Jsf Config -->
  <context-param> 
  	<param-name>org.ajax4jsf.SKIN</param-name> 
  	<param-value>blueSky</param-value> 
  </context-param> 
  
  <filter> 
  	<display-name>Ajax4jsf Filter</display-name> 
  	<filter-name>ajax4jsf</filter-name> 
  	<filter-class>org.ajax4jsf.Filter</filter-class> 
  </filter>   
  
  <filter-mapping> 
  <filter-name>ajax4jsf</filter-name> 
	<servlet-name>Faces Servlet</servlet-name>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>INCLUDE</dispatcher>
  </filter-mapping>  
  
  <!-- Spring Config -->
  <context-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.web.context.support.XmlWebApplicationContext</param-value>
  </context-param>

  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:applicationContext.xml
            classpath*:applicationContext-localDataSource.xml
            classpath*:applicationContext-jsf.xml
            classpath*:applicationContext-service.xml
            classpath*:applicationContext-jsf-security.xml
        </param-value>
  </context-param>
  
   <filter>
        <filter-name>Acegi Filter Chain Proxy</filter-name>
        <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
        <init-param>
            <param-name>targetClass</param-name>
            <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
        </init-param>
    </filter>

    <filter-mapping>
      <filter-name>Acegi Filter Chain Proxy</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>REQUEST</dispatcher>      
    </filter-mapping>  
    
  <!-- Tiles Config -->
  <context-param>
        <param-name>tiles-definitions</param-name>
        <param-value>/WEB-INF/tiles-config.xml</param-value>
  </context-param>
    
  <!-- JSF 1.1 Standard Config -->
  <context-param>
    <description>Comma separated list of URIs of (additional) faces config files.
            (e.g. /WEB-INF/my-config.xml)
            See JSF 1.0 PRD2, 10.3.2
            Attention: You do not need to put /WEB-INF/faces-config.xml in here.
    </description>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
  </context-param>
  
  <!-- MyFaces 1.1 Config -->  
  <context-param>
    <description>State saving method: "client" or "server" (= default)
            See JSF Specification 2.5.3</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default).
            Defines the amount (default = 20) of the latest views are stored in session.</description>
    <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
    <param-value>20</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default).
            If true (default) the state will be serialized to a byte stream before it 
            is written to the session.
            If false the state will not be serialized to a byte stream.</description>
    <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>Only applicable if state saving method is "server" (= default) and if 
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
            If true (default) the serialized state will be compressed before it 
            is written to the session. If false the state will not be compressed.</description>
    <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>This parameter tells MyFaces if javascript code should be allowed in the
            rendered HTML output.
            If javascript is allowed, command_link anchors will have javascript code
            that submits the corresponding form.
            If javascript is not allowed, the state saving info and nested parameters
            will be added as url parameters.
            Default: "true"</description>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <description>If true, rendered HTML code will be formatted, so that it is "human readable".
            i.e. additional line separators and whitespace will be written, that do not
            influence the HTML code.
            Default: "true"</description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>If true, a javascript function will be rendered that is able to restore the
            former vertical scroll on every request. Convenient feature if you have pages
            with long lists and you do not want the browser page to always jump to the top
            if you trigger a link or button action that stays on the same page.
            Default: "false"</description>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
  </context-param>

  <context-param>
	<description>Validate managed beans and navigation rules.</description>
    <param-name>org.apache.myfaces.validate</param-name>
    <param-value>true</param-value>
  </context-param>

<!--
  <context-param>
    <description>A class implementing the
		    org.apache.myfaces.shared.renderkit.html.util.AddResource
		    interface. It is responsible to
   			place scripts and css on the right position in your HTML document.
            Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"</description>
    <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
    <param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
  </context-param>
-->
  
  <!-- MyFaces Tomahawk Config -->
  <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
      <description>Set the size limit for uploaded files.
                Format: 10 - 10 bytes
                        10k - 10 KB
                        10m - 10 MB
                        1g - 1 GB</description>
      <param-name>uploadMaxFileSize</param-name>
      <param-value>100m</param-value>
    </init-param>
    <init-param>
      <description>Set the threshold size - files
                    below this limit are stored in memory, files above
                    this limit are stored on disk.

                Format: 10 - 10 bytes
                        10k - 10 KB
                        10m - 10 MB
                        1g - 1 GB</description>
      <param-name>uploadThresholdSize</param-name>
      <param-value>100k</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/faces/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>SourceCodeServlet</servlet-name>
    <servlet-class>org.apache.myfaces.shared_tomahawk.util.servlet.SourceCodeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>SourceCodeServlet</servlet-name>
    <url-pattern>*.source</url-pattern>
  </servlet-mapping>
  
  <!-- Standard config -->
  <session-config>
  	<session-timeout>5</session-timeout>
  </session-config>
  
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  
  <error-page>
	<error-code>500</error-code>
	<location>/error.jsf</location>
  </error-page>
</web-app>

Este arquivo esta dentro da pasta projeto/webcontent/web-inf