[jboss-user] [JBoss Web Services] - CXF Endpoint not autowiring spring beans

Shameer Kunjumohamed do-not-reply at jboss.com
Tue Aug 14 11:00:24 EDT 2012


Shameer Kunjumohamed [https://community.jboss.org/people/skunjumohamed] created the discussion

"CXF Endpoint not autowiring spring beans"

To view the discussion, visit: https://community.jboss.org/message/753601#753601

--------------------------------------------------------------
Hi,

CXF endpoint is not properly integrated with spring. I am using JBoss AS 7.1.1 to deploy my cxf webservice integrated with spring. The log messages shows that both CXF and spring creates two different instances of the endpoint bean, and only the spring-created bean is autowired. 

The CXF created instance does not have the dependencies set and it is the one who listens to the client requests, and throws null pointers.

Here is the code..

Service Interface..

package test.cxf.service;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;


@WebService(name = "EchoService", targetNamespace = " http://service.cxf.test/ http://service.cxf.test/")
public interface EchoService {

    @WebMethod(operationName = "echo", action = "urn:Echo")
    String echo(@WebParam(name = "message") String message);

}


Service implementation (Endpoint)

package test.cxf.service;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service("EchoService")
@WebService(endpointInterface = "test.cxf.service.EchoService", serviceName = "EchoService")
public class EchoServiceImpl implements EchoService {

    @Autowired
    private SystemInfoBean sysInfoBean;

    public EchoServiceImpl() {
        System.out.println(">>>>>>>>> " + this.getClass().getName() + "-constructed.");
    }

    @Value("Fooooooooooooo Baaaaaaaaaar")
    public void setTestInjection(String value) {
        System.out.println(">>>>>>>> Test Injection value = " + value);
    }

    @WebMethod
    public @WebResult(name="result") String echo(@WebParam(name="message") String message) {
        System.out.println(">>>>>>>> Inside " + this.getClass().getClass().getName() + "-echo - message = " + message);
        System.out.println(" Echoing " + message);

        sysInfoBean.printOSInfo();

        return message;
    }

}


SystemInfoBean - A dependent bean

package test.cxf.service;

import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;

import org.springframework.stereotype.Component;

@Component
public class SystemInfoBean {

    public SystemInfoBean() {
        // TODO Auto-generated constructor stub
    }

    public void printOSInfo() {
        OperatingSystemMXBean osXBean = ManagementFactory.getOperatingSystemMXBean();
        System.out.println("============ Operating System Information=========");
        System.out.println("Operating System: " + osXBean.getName());
        System.out.println("Version: " + osXBean.getVersion());
        System.out.println("Architecture: " + osXBean.getArch());
        System.out.println("Available Processors: " + osXBean.getAvailableProcessors());
        System.out.println("==================================================");
    }

}


Spring configuration (beans.xml)




web.xml




I am excluding the JBoss CXF modules or implementation jars in the jboss-deployment-structure.xml





Thanks for any help in advance.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/753601#753601]

Start a new discussion in JBoss Web Services at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120814/0773a089/attachment.html 


More information about the jboss-user mailing list