Erro aplicacao com Spring e Serlvet

0 respostas
soloplayer

Olá pessoal desenvolvi um exemplo com Spring e não sei o porque ao tentar efetuar um teste unitario no AlunoServiceImpl ele sempre traz null, faço isso:

package br.com.siscom.model.facade;

import java.util.List;

import br.com.siscom.model.bean.Aluno;
import br.com.siscom.model.service.AlunoService;

public class Facade {


	private AlunoService alunoService;

	
	public List<Aluno> select(){
		
		alunoService.select();
		return null;
		
	}
	
	public void setAlunoService(AlunoService alunoService) {
		this.alunoService = alunoService;
	}	

	
}

E o alunoService vem sempre NULL, já quando chamo do servlet da certo, segue meu xml.

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
  - Application context definition for JPetStore's business layer.
  - Contains bean references to the transaction manager and to the DAOs in
  - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
  -->
<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:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	
	<!-- MAPEAMENTO DOS SERVICOS IOC SPRING -->
   	<bean id="alunoService" class="br.com.siscom.model.service.impl.AlunoServiceImpl" lazy-init="false" scope="singleton">
		<property name="alunoDAO" ref="alunoDAO" />
	</bean> 

 	<bean id="clienteService" class="br.com.siscom.model.service.impl.ClienteServiceImpl" lazy-init="false" scope="singleton">
		<property name="clienteDAO" ref="clienteDAO" />
	</bean> 

	<bean id="pessoaService" class="br.com.siscom.model.service.impl.PessoaServiceImpl" lazy-init="false" scope="singleton">
		<property name="pessoaDAO" ref="pessoaDAO" />
	</bean>


	
	
	<!-- MAPEAMENTO DOS DAOS IOC SPRING -->
   	<bean id="alunoDAO" class="br.com.siscom.model.dao.impl.AlunoDAOImpl" init-method="init" lazy-init="false" scope="singleton">
		<property name="jdbcTemplate" ref="jdbcTemplate" />
	</bean> 

 	<bean id="clienteDAO" class="br.com.siscom.model.dao.impl.ClienteDAOImpl" init-method="init" lazy-init="false" scope="singleton">
		<property name="jdbcTemplate" ref="jdbcTemplate" />
	</bean> 

	<bean id="pessoaDAO" class="br.com.siscom.model.dao.impl.PessoaDAOImpl" init-method="init" lazy-init="false" scope="singleton">
		<property name="jdbcTemplate" ref="jdbcTemplate" />
	</bean>


	<!-- arquivo properties -->
	<context:property-placeholder location="classpath:resources/jdbc.properties" />
	
	<!-- Config. datasource -->
 	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
		  destroy-method="close"
		  p:driverClassName="${jdbc.driverClassName}" 
		  p:url="${jdbc.url}" 
		  p:username="${jdbc.username}"
		  p:password="${jdbc.password}" />
 
  
		  
	<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
	<bean id="transactionManager" 
	      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
		  p:dataSource-ref="dataSource"/>

	<!-- JDBC template -->
	<bean
		id="jdbcTemplate"
		class="org.springframework.jdbc.core.JdbcTemplate"
		lazy-init="false">
			<property name="dataSource" ref="dataSource" />
			<property name="lazyInit" value="false" />
	</bean>

</beans>

é um exemplo bem simples mais ainda não consegui entender a logica o porque ele pelo servlet da certo e ao tentar chamar direto o service sempre retorna null. Grato

Criado 20 de janeiro de 2012
Respostas 0
Participantes 1