我正在使用Spring编写一个用于依赖注入的CXF / Maven Web服务。以下是我的网络服务代码: -
@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;
}
}
在我的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>
我已经使用提供的范围标记了所有CXF依赖项,以便在JBoss文件夹中使用CXF库。我不得不将以下jar复制到JBoss的default \ lib文件夹中,以满足所需的依赖关系。
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
我的应用服务器是JBoss。当我部署战争并启动服务器时,我收到以下错误: -
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]
我认为“/”是applicationContext.xml中给出的服务定义中给出的地址。为什么我收到上述错误,我该如何解决?非常感谢您的帮助。