0

I am writing a CXF/Maven web service with Spring for dependency injection. Following is my web service code:-

@Path("/myws")
public interface IMyWebService {    
    @POST
    @Path("/someAction")    
    @Consumes("application/json")
    @Produces("application/json")
    MyResponse requestSomeAction(MyRequest requestObj);
}

@Service("myWebService")
public class MyWebService implements IMyWebService {    
    @Autowired
    private IMyCoreService myCoreService;

    public MyResponse requestSomeAction(MyRequest requestObj) {
        // do some work
        return myResponse;
    }
}

And in my applicationContext.xml....

<context:component-scan base-package="com.company.project" />
<bean id="myCore" class="com.company.project.module.MyCoreService" />

<jaxrs:server id="restContainer" address="/">
    <jaxrs:serviceBeans>
        <bean class="com.company.project.module.MyWebService" />
    </jaxrs:serviceBeans>
    <jaxrs:features>
        <cxf:logging />
    </jaxrs:features>
    <jaxrs:providers>
        <bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
    </jaxrs:providers>
</jaxrs:server>

I have marked all CXF dependecies with scope as provided so as to use the CXF libraries in the JBoss folders. I had to copy the following jars to the JBoss's default\lib folder to meet the required dependencies.

cxf-rt-frontend-jaxrs.jar
aopalliance.jar
spring core jars
org.springframework.orm-3.0.0.RELEASE.jar
org.springframework.jdbc-3.0.0.RELEASE.jar
org.springframework.beans-3.0.0.RELEASE.jar
org.springframework.context-3.0.0.RELEASE.jar
com.springsource.org.hibernate.ejb-3.4.0.jar

My app server is JBoss. When I deploy the war and start the server, I get the following error:-

Caused by: java.net.MalformedURLException: no protocol: /
        at java.net.URL.<init>(URL.java:567) [:1.6.0_33]
        at java.net.URL.<init>(URL.java:464) [:1.6.0_33]
        at java.net.URL.<init>(URL.java:413) [:1.6.0_33]
        at org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerDestination.<init>(HttpServerDestination.java:67) [:3.4.1.GA]
        at org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory.createDestination(HttpServerTransportFactory.java:102) [:3.4.1.GA]
        at org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory.getDestination(HttpServerTransportFactory.java:91) [:3.4.1.GA]
        at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:92) [:2.3.1]
        at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:71) [:2.3.1]
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:95) [:2.3.1]

I think the "/" is the address given in the service definition given in the applicationContext.xml. Why I am getting the above error, and how do i resolve it? Your help highly appreciated.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Higher-Kinded Type
  • 1,964
  • 5
  • 27
  • 44
  • 1
    possible duplicate: http://stackoverflow.com/questions/3793034/web-service-using-cxf-jetty-and-spring – guido Jul 02 '12 at 09:40
  • @guido I think I got past this error based on your comment but what happens is that my beans are not being injected into the web service, even if the class being injected is as empty as possible with no dependencies. Any way it is related to this? – Higher-Kinded Type Jul 02 '12 at 17:24

0 Answers0