Hi all
My application back-end,spring based and deployed in Tomcat 7, is composed by four different .jar and one .war,which contains jax-ws interfaces webservice,and use the mentioned jars:
1)ServiceWS.war:
JAX-WS interfaces to expose business-service as webservice. Here,under "resource" folder,was located Spring application-context.xml
2) Business.jar and Dao..jar first contains Business Logic and second contains Data Acess Logic. The Business Logic Bean was annotad with @Service and the Data Access Bean was annotad with @RepositoryCode:<?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:annotation-config /> <context:component-scan base-package="it.company.myapp.ws.impl"/> <context:component-scan base-package="it.company.myapp.business.services.impl"/> <context:component-scan base-package="it.company.myapp.persistence.dao.impl"/> <!-- Other stuff --> .... ....
In the application-context.xml,as you can see, i refer to classes in the business.jar and dao.jar by:
So,In my ws service:Code:<context:component-scan base-package="it.company.myapp.business.services.impl"/> <context:component-scan base-package="it.company.myapp.persistence.dao.impl"/>
So,when Tomcat 7 server starts all seems to work and console shows me a message saying that Spring context was correctly loaded! But when I try to invoke ws-service (executeSum) I have NULL-POINTER on the "services" property.Code:@Component @[...Other Jax-Ws Annotation...] public ProxyWS{ /* property which refers to interface in the business.jar. It's implementation class is annotated with @Service */ @Autowired private IBusinessServices services; public int executeSum(int a,int b) { return services.sum(a,b); } }
P.S.:
Consider if i change the:
and insert a package which not exist, an exception on server startup is thrown:Code:<context:component-scan base-package="it.company.myapp.business.services.impl"/>
Any suggestion?Code:Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: it.company.myapp.business.services.IBusinessServices it.company.myapp.ws.impl.ProxyWS.service; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [it.company.myapp.business.services.IBusinessServices] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) ... 21 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [it.company.myapp.business.services.IBusinessServices] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478) ... 23 more


Reply With Quote
