Descoberta Automática de Beans utilizando JSF e Spring

Pessoal, fiz várias tentativas utilizando as dicas de vocês mas ainda não consegui resolver o problema. O bean é retornado nulo. Alguém pode me explicar passo a passo como devo fazer ???
Alguém me dá mais uma força aí ?

Vou mostrar como eu uso. Também é JSF 1.2 e Spring:

web.xml:

 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>

faces-config.xml:

	<application>
	
	   <resource-bundle>
			<base-name>message</base-name>
			<var>msg</var>
		</resource-bundle>
	
		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
		<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
	</application>

applicationContext.xml:

<bean
		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
	<bean
		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

	
	<bean id="contextApplicationContextProvider" class="context.ApplicationContextProvider" />
	<tx:annotation-driven />

	<context:component-scan base-package="*" />

Exemplo de uso:

Bean injetado:

@Component
public class ProjetoDaoImp extends GenericDaoImp<Projeto,Long>
implements ProjetoDao{
@Component
public class ProjetoController {

	@Resource
	ProjetoDao dao;

[quote=raf4ever]Vou mostrar como eu uso. Também é JSF 1.2 e Spring:

web.xml:

 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>

faces-config.xml:

	<application>
	
	   <resource-bundle>
			<base-name>message</base-name>
			<var>msg</var>
		</resource-bundle>
	
		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
		<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
	</application>

applicationContext.xml:

<bean
		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
	<bean
		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

	
	<bean id="contextApplicationContextProvider" class="context.ApplicationContextProvider" />
	<tx:annotation-driven />

	<context:component-scan base-package="*" />

Exemplo de uso:

Bean injetado:

@Component
public class ProjetoDaoImp extends GenericDaoImp<Projeto,Long>
implements ProjetoDao{
@Component
public class ProjetoController {

	@Resource
	ProjetoDao dao;
[/code][/quote]


raf4ever, o projeto não roda...dá aquele erro: HTTP Status 503...
vou te passar como estão os meus arquivos

web.xml

[code]<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <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>dispatcher</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/welcomeJSF.jsp</welcome-file>
    </welcome-file-list>
</web-app>

faces-config.xml

[code]<?xml version=‘1.0’ encoding=‘UTF-8’?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd”>

&lt;application&gt;

    &lt;resource-bundle&gt;
        &lt;base-name&gt;message&lt;/base-name&gt;
        &lt;var&gt;msg&lt;/var&gt;
    &lt;/resource-bundle&gt;

    &lt;view-handler&gt;com.sun.facelets.FaceletViewHandler&lt;/view-handler&gt;
    &lt;el-resolver&gt;org.springframework.web.jsf.el.SpringBeanFacesELResolver&lt;/el-resolver&gt;
&lt;/application&gt;

</faces-config>
[/code]

welcomeJSF.jsp

&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;

&lt;%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%&gt;
&lt;%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%&gt;

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;

&lt;%--
    This file is an entry point for JavaServer Faces application.
--%&gt;
&lt;f:view&gt;
    &lt;h:form&gt;
        &lt;h:outputText value="Usuário: "/&gt;
        &lt;h:inputText value="#{Controle.usuario}"/&gt;
        &lt;h:outputText value="Senha: "/&gt;
        &lt;h:inputText value="#{Controle.senha}"/&gt;
    &lt;/h:form&gt;
&lt;/f:view&gt;

applicationContext.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
    
    &lt;bean
		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /&gt;
    &lt;bean
		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;


    &lt;bean id="contextApplicationContextProvider" class="context.ApplicationContextProvider" /&gt;
    &lt;tx:annotation-driven /&gt;

    &lt;context:component-scan base-package="controle" /&gt;

&lt;/beans&gt;

meu controlador(bean):

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controle;

import org.springframework.stereotype.Component;

@Component
public class Controle {

    private String usuario;
    private String senha;

    public Boolean login() {
        if (getUsuario().equals("admin") && getSenha().equals("admin")) {
            return true;
        }
        return false;
    }

    public String getSenha() {
        if (senha == null) {
            senha = "";
        }
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public String getUsuario() {
        if (usuario == null) {
            usuario = "";
        }
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }
}

fiz este método login que é chamado pelo commandButton bem simples só para caráter de teste mesmo…

Fiz também a validação do arquivo applicationContext.xml após colocar as configurações que você me passou e ele me retornou o seguinte erro:

The prefix "context" for element "context:component-scan" is not bound. [34] 

Ainda precisa de algumas modificações:

Pode retirar esses dois trechos:

 &lt;context-param&gt;  
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;  
        &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;  
    &lt;/context-param&gt;  

  &lt;servlet&gt;  
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;  
        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
        &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;  
    &lt;/servlet&gt;  

E adapta o cabeçalho do teu applicationContext.xml de acordo com esse:

&lt;beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
       http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-2.5.xsd 
       http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt;

[quote=raf4ever]Ainda precisa de algumas modificações:

Pode retirar esses dois trechos:

 &lt;context-param&gt;  
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;  
        &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;  
    &lt;/context-param&gt;  

  &lt;servlet&gt;  
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;  
        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
        &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;  
    &lt;/servlet&gt;  

E adapta o cabeçalho do teu applicationContext.xml de acordo com esse:

&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt; [/quote]

Cara, parece que está quase dando certo…
agora faltou componente dispatcher, olha a saída da IDE:

Deploying application in domain failed; Error loading deployment descriptors for module [PROJETO] -- There is no web component by the name of dispatcher here. /home/NetBeansProjects/PROJETO/nbproject/build-impl.xml:713: O módulo não foi implementado. FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)

Vixe,esse erro eu nunca vi.Tá usando qual servidor de aplicacao?

Glassfish 2.1

Glassfish 2.1[/quote]

É mandatório usar um AS full-stack? Tinha como testar num Tomcat da vida?