0

我正在使用 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中给出的服务定义中给出的地址。为什么我收到上述错误,我该如何解决?非常感谢您的帮助。

4

0 回答 0