Announcement Announcement Module
Collapse
No announcement yet.
dependency inject in web services Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • dependency inject in web services

    Hi ,

    i have the following code:

    applicationcontext.xml

    <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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schem...ng-aop-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">


    <context:component-scan base-package="xxx.adapter"/>

    <context:component-scan base-package="xxx.referral"/>

    </beans>

    web.xml
    <?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/Spring/applicationContext.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    </web-app>

    class


    @Service
    @SchemaValidation(handler = MyErrorHandler.class)
    @javax.jws.WebService( endpointInterface = "com.xxx.xxx.xxx.ws.wsinterface.cms2ppc.CMS2PPCSer viceInterface", targetNamespace = "http://xxx.com/xxx", serviceName = "xxx", portName = "xxx")
    public class CMS2PPCServiceImpl {

    @Autowired
    CmsToCoreReferralServiceAdapter cmsToCoreReferralServiceAdapter;
    }

    CmsToCoreReferralServiceAdapter class is from another project which i included it as a jar file.

    CmsToCoreReferralServiceAdapterImpl is in package xxx.adapter

    @Service("CmsToCoreReferralServiceAdapterImpl")
    public class CmsToCoreReferralServiceAdapterImpl implements CmsToCoreReferralServiceAdapter {}

    the problem is when i use cmsToCoreReferralServiceAdapter, it says it is null. please help me.

  • #2
    I believe you still need to define a bean with id cmsToCoreReferralServiceAdapter. Alternatively you may be able to annotate your CmsToCoreReferralServiceAdapter class with @Component or @Repository.

    Comment

    Working...
    X