Bonjour à tous,

Je vous sollicite car je suis sur un problème de paramétrage Spring depuis 2 jours et je n'arrive pas à trouver ce qui ne vas pas :
J'ai un tout petit projet JEE avec spring 3.2.17. Pour cette appli j'ai donc créé dans mon arbo le fichier suivant WEB-INF/spring/applicationContext.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd            
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd">
 
	<!-- ANNOTATIONS POUR LA CREATION DE BEANS -->
	<context:component-scan base-package="com.appli.fourniture" />       
</beans>
Ensuite dans mon web.xml j'ai ajouté ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
<context-param>   
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:WEB-INF/spring/applicationContext.xml</param-value>
 </context-param>   
   <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

J'ai ensuite tout bonnement créer un WebService qui utilise une classe ayant l'entête suivante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
@Service("alimentationService")
public class AlimentationsServiceImpl implements AlimentationService {

Mon WebService a une entête suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
@WebService(name = "Alimentation", serviceName = "WS")
public class AlimentationWebServiceImpl implements AlimentationWebService {
 
    @Autowired
    private AlimenationService alimentationsService;

Mon problème c'est que lorsque j'essaie d'utiliser la propriété "alimentationsService" j'ai un null pointer exeception.

J'ai donc plusieurs questions :
1 - Comment puis-je m'assurer que mon fichier applicationContext.xml est bien pris en compte ?
2- Comme je pensais que le fichier n'était pas pris en compte j'ai fait un petit test :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:WEB-INF/spring/applicationContext.xml");
        String test = context.getApplicationName();
        System.out.println("Nb : " + context.getBeanDefinitionCount());
        System.out.println("Nb : " + context.getBeansOfType(Converter.class).toString());
J'ai remarqué qu'avec ce bout de code je charge bien mon fichier (car si je donne un nom bidon j'ai un FileNotExist) par contre je n'ai aucun élément scanné.

Qu'ai-je raté ? Avez vous une idée ?


Merci beaucoup !