IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Spring + component + jaxws


Sujet :

Spring Java

  1. #1
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut Spring + component + jaxws
    Bonjour à tous,

    Dans ma webapp, j'ai deux beans (Foo et DailyFluxWS) annotés avec @component. Chacun reçoit une série de beans en @autowired. Or ça marche avec Foo mais pas avec DailyFluxWS pour lequel je me mange une NPE :-(

    Voici à quoi ressemblent mes beans :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    @Component
    public class Foo  implements Serializable {
     
       @Autowired
        private FluxService fluxService ;
     
        @PostConstruct
        public void postConstruct() {
    	System.out.println("foo");
    	System.out.println("fluxService:" + fluxService);
        }
     
    ...
    et

    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
     
    @WebService
    @SOAPBinding(style = Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
    @Component
    public class DailyFluxWS implements Serializable {
     
       @Autowired
        private FluxService fluxService ;
     
       @WebMethod(exclude = true)
        @PostConstruct
        public void postConstruct() {
    	System.out.println("dailyflux...");
    	System.out.println("fluxService:" + fluxService);
        }
     
    ...
    La grosse différence est que DailyFlux est un web service.

    Quand je lance Tomcat 7, j'ai la trace suivante :

    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
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
     
    8 janv. 2013 09:17:56 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\dev\javas\jdk1.6.0_24\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\dev\mavens\apache-maven-3.0.3-bin\apache-maven-3.0.3\bin;C:\dev\commandes;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Druide\Antidote 7\Programmes32;C:\Program Files (x86)\Druide\Antidote 7\Programmes64;C:\Program Files (x86)\Common Files\DivX Shared\;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\QuickTime\QTSystem\;C:\dev\gos\go1.0.3\go\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live
    8 janv. 2013 09:17:56 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:C4RegroupWS' did not find a matching property.
    8 janv. 2013 09:17:56 org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    8 janv. 2013 09:17:56 org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    8 janv. 2013 09:17:56 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 792 ms
    8 janv. 2013 09:17:56 org.apache.catalina.core.StandardService startInternal
    INFO: Démarrage du service Catalina
    8 janv. 2013 09:17:56 org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
    dailyflux...
    fluxService:null
    8 janv. 2013 09:18:02 com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init>
    INFO: WSSERVLET14: JAX-WS servlet initializing
    8 janv. 2013 09:18:02 org.apache.catalina.core.ApplicationContext log
    INFO: No Spring WebApplicationInitializer types detected on classpath
    8 janv. 2013 09:18:02 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
    INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 08 09:18:02 CET 2013]; root of context hierarchy
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/applicationContext.xml]
    INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/db.xml]
    INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [regroup_ws_conf.properties]
    INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@79b2591c: defining beans [dailyFluxWS,foo,someManager,driveDaoImpl,driveService,fluxService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,messageSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
    WARN : org.hibernate.ejb.Ejb3Configuration - HHH000059: Defining hibernate.transaction.flush_before_completion=true ignored in HEM
    WARN : org.hibernate.engine.jdbc.internal.JdbcServicesImpl - HHH000342: Could not obtain connection to query metadata : Cannot create PoolableConnectionFactory (Communications link failure
     
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
    dailyflux...
    fluxService:com.carrefour.regroup.service.flux.FluxService@4cd98b00
    foo
    fluxService:com.carrefour.regroup.service.flux.FluxService@4cd98b00
    INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 3711 ms
    8 janv. 2013 09:18:05 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
    INFO: WSSERVLET12: JAX-WS context listener initializing
    8 janv. 2013 09:18:05 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
    INFO: WSSERVLET12: JAX-WS context listener initializing
    INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
    8 janv. 2013 09:18:05 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'appServlet'
    INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Tue Jan 08 09:18:05 CET 2013]; parent: Root WebApplicationContext
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/app/servlet-context.xml]
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/app/controllers.xml]
    INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
    INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6f77e5d4: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,dailyFluxWS,foo,someManager,driveDaoImpl,driveService,fluxService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#1,org.springframework.format.support.FormattingConversionServiceFactoryBean#1,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#1,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#1,org.springframework.web.servlet.handler.MappedInterceptor#1,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#1,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#1,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#1,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#1,validator,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@79b2591c
    INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
    dailyflux...
    fluxService:com.carrefour.regroup.service.flux.FluxService@1afb7ac7
    foo
    fluxService:com.carrefour.regroup.service.flux.FluxService@1afb7ac7
    INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1'
    INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 808 ms
    .....

    Ce qui me gène, c'est déjà que les méthodes postconstrct soient appellées deux fois, mais aussi la ligne suivante dans le premier appel :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
    dailyflux...
    fluxService:null

    Au niveau de mon web.xml, ça ressemble à ça :

    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
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
     
    <web-app version="3.0" 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_3_0.xsd">
     
     
    	<display-name>C4RegroupWS</display-name>
     
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/spring/applicationContext.xml
    		</param-value>
    	</context-param>
    	<filter>
    		<filter-name>spring-encoding-filter</filter-name>
    		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    		<init-param>
    			<param-name>encoding</param-name>
    			<param-value>UTF-8</param-value>
    		</init-param>
    	</filter>
     
    	<filter-mapping>
    		<filter-name>spring-encoding-filter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
     
     
     
    	<filter>
    		<filter-name>localizationFilter</filter-name>
    		<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>localizationFilter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
     
     
     
     
     
     
     
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<listener>
    		<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
    	</listener>
     
     
     
     
    	<servlet>
    		<servlet-name>appServlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>/WEB-INF/spring/app/servlet-context.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>appServlet</servlet-name>
    		<url-pattern>/*</url-pattern>
    	</servlet-mapping>
     
    	<servlet>
    		<servlet-name>WSServlet</servlet-name>
    		<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>WSServlet</servlet-name>
    		<url-pattern>/DailyFluxWS</url-pattern>
    	</servlet-mapping>
     
    	...
    A mon avis, c'est un truc tellement énorme que j'arrive pas à le voir...

    Quelqu'un peut m'aider ?
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  2. #2
    Membre Expert
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 964
    Par défaut
    Citation Envoyé par thierryler Voir le message
    ...

    La grosse différence est que DailyFlux est un web service.

    ...

    Ce qui me gène, c'est déjà que les méthodes postconstrct soient appellées deux fois,
    ...

    A mon avis, c'est un truc tellement énorme que j'arrive pas à le voir...
    ben si vous l'avez vu : les methodes sont appelées 2x
    mais vous n'en tirez pas la conclusion qui s'impose :

    2 objets sont créés dont un seul est instrumenté mais c'est celui qui n'est pas instrumenté qui est utilisé par le WS d'où la NPE.

    si je me souviens bien ce même problème a déjà été invoqué dans un forum ici mais concernant Axis, et il y avait plusieurs solutions.

  3. #3
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Oui j'en suis arrivé à la même conclusion. Mais comment dire au web service d'utiliser le bon ?...
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  4. #4
    Membre Expert
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Par défaut
    Tu pourrais mettre ton applicationContext.xml et tout autre fichier de config spring stp ?

  5. #5
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Voici les fichiers.

    sun-jaxws.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    <?xml version="1.0" encoding="UTF-8"?>
    <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
    	version="2.0">
     
    	<endpoint name="DailyFluxWS" implementation="com.masociete.monprojet.ws.DailyFluxWS"
    		url-pattern="/DailyFluxWS" />
    </endpoints>
    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
     
    <beans xmlns="http://www.springframework.org/schema/beans"
    	   xmlns:context="http://www.springframework.org/schema/context"
    	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
     
    	<!-- Root Context: defines shared resources visible to all other web components -->
    	<context:component-scan base-package="com.masociete.monprojet" />
    <import resource="db.xml" />
     
    	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    		<property name="basename"
    				  value="classpath:org/springframework/security/messages" />
    	</bean>
    controllers.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
    18
    19
    20
    21
    22
    23
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    	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-3.0.xsd
    		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd	
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
     
    	<!-- Scans within the base package of the application for @Components to 
    		configure as beans -->
    	<context:component-scan base-package="com.masociete" />
     
    	<tx:annotation-driven />
    	<mvc:annotation-driven />
     
    	<mvc:resources mapping="/resources/**" location="/resources/" />
     
    	<bean id="validator"
    		class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
     
    </beans>
    servlet-context.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
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
     
    	xsi:schemaLocation="
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
     
    	<!-- DispatcherServlet Context: defines this servlet's request-processing 
    		infrastructure -->
     
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<annotation-driven />
     
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    		up static resources in the ${webappRoot}/resources directory -->
    	<resources mapping="/resources/**" location="/resources/" />
     
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    		in the /WEB-INF/views directory -->
    	<beans:bean
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
     
    	<!-- Imports user-defined @Controller beans that process client requests -->
    	<beans:import resource="controllers.xml" />
     
    </beans:beans>
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  6. #6
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    Ce que je comprends c'est que tu charges deux fichiers de configuration Spring:
    - applicationContext.xml
    - servlet-context.xml qui inclut controllers.xml et qui redéfinit le context:component-scan base-package de applicationContext.xml
    d'où les objets créés deux fois.

    Il me semble également que le container créé également un objet pour ton WS mappé sur ton URL mais qui est différent des deux objets créés par Spring, et comme ce n'est pas un objet managé, l'injection de ton service échoue.

  7. #7
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Effectivement je me suis un peu loupé... Du coup, tu supprimerais lequel toi ? Et surtout, comment faire en sorte que le ws soit managé ?
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  8. #8
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    Tu peux essayer de faire hériter ta classe DailyFluxWS de SpringBeanAutowiringSupport.

    Si c'est contre tes principes, regarde la doc pour la méthode la plus appropriée, je n'ai pas expérimenté davantage.

  9. #9
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Tu peux essayer de faire hériter ta classe DailyFluxWS de SpringBeanAutowiringSupport.
    Ça ne marche pas :-(
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  10. #10
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    rien de particulier :-(

    J'ai même pensé un moment qu'il y avait une incompatibilité entre javws et spring mais ça n'a pas l'air de venir de là. C'est bien deux context comme on a déjà vu. Et dans le context ws il ne lance pas spring
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  11. #11
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    Tu as viré l'annotation component sur ton WS ?

  12. #12
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    oui bien sur je l'ai virré
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  13. #13
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    J'ai essayé avec et sans :

    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
    18
     
    @WebService
    // @SOAPBinding(style = Style.RPC)
    @SOAPBinding(style = Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
    @Component
    public class DailyFluxWS extends SpringBeanAutowiringSupport implements Serializable {
     
       @Autowired
        private FluxService fluxService;
     
       @WebMethod(exclude = true)
        @PostConstruct
        public void postConstruct() {
     
     
    	System.out.println("dailyflux...");
    	System.out.println("fluxService:" + fluxService);
        }
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  14. #14
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Je précise. J'ai Tomcat 7 et jaxws-rt 2.2.5
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  15. #15
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    et si tu positionnes le load-on-startup de ta WSServlet à 2, pour etre certain que le contexte Spring soit configuré avant.

    tu as réglé le problème du double chargement ?

  16. #16
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    Sinon jette un oeil à ça: http://jax-ws-commons.java.net/spring/

  17. #17
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    Alors, mettre à 2 ne change rien.

    Et non je n'ai pas encore réglé le doublon.
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  18. #18
    Membre Expert
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Par défaut
    La solution je pense est dans le lien donné :
    <wss:binding url="/sub">
    <wss:service><!-- nested bean is of course fine -->
    <ws:service bean="#myService" />
    </wss:service>
    </wss:binding>
    pour déclarer ton web service dans Spring (sinon c'est effectivement une autre instance et non ton bean Spring qui est utilisé donc pas d'injection)

  19. #19
    Rédacteur
    Avatar de thierryler
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    4 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 078
    Par défaut
    heu ?...
    Thierry Leriche-Dessirier
    Consultant Java JEE Web Agile freelance
    Rédacteur pour Developpez
    Professeur de Génie Logiciel à l'ESIEA

    Site : http://www.icauda.com / Linked'in : http://www.linkedin.com/in/thierryler / Twitter : @ThierryLeriche

  20. #20
    Membre Expert
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Par défaut
    Là tu déclares ton web service dans sun-jaxws.xml, donc hors contexte Spring et tu ne peux pas bénéficier de l'injection Spring.
    Ce qui est expliqué dans le lien donné par fr1man, c'est comment déclarer ton web service dans Spring, cf l'extrait que je t'ai mis auparavant.

Discussions similaires

  1. "component" sur autre base de données
    Par k4eve dans le forum Hibernate
    Réponses: 4
    Dernier message: 12/04/2005, 10h48
  2. [FLASH MX 2004]Scrollpane component
    Par cavo789 dans le forum Flash
    Réponses: 10
    Dernier message: 23/06/2004, 12h18
  3. comment acceder a un component lui meme dans un panel
    Par mimosa7 dans le forum Composants
    Réponses: 2
    Dernier message: 17/11/2003, 00h02
  4. [Crystal report] Component
    Par Antichoc dans le forum SAP Crystal Reports
    Réponses: 4
    Dernier message: 24/04/2003, 17h11
  5. Component not found
    Par Pm dans le forum XMLRAD
    Réponses: 2
    Dernier message: 28/01/2003, 15h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo