jboss fuse 6.2 rest cxf org.apache.cxf.service.factory.ServiceConstructionException:“找不到资源类”

时间:2015-08-08 05:28:27

标签: rest deployment cxf jbossfuse

刚开始使用6.1中的Fuse 6.2。这部署在6.1上,我似乎无法在新的Fuse 6.2中部署它。 当我部署到Fuse环境时,这个简单的Rest服务不断收到以下错误。

非常感谢任何想法。

这个问题建议从Fuse中删除javax.ws.rs/javax.ws.rs-api/2.0.1捆绑文件。捆绑包干净地启动而没有错误,但由于某种原因无法访问REST服务。

此链接可能适用: https://issues.apache.org/jira/browse/CXF-5654

我需要调查Swagger功能,因为它会自动启动。

错误:

Caused by: org.apache.cxf.service.factory.ServiceConstructionException: No resource classes found
        at org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:317)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:159)
        ... 29 more

代码:

@Path("/configservice")
public class ConfigurationServiceImpl 
{

    public ConfigurationServiceImpl()
    {
    }


    @GET
    @Path("/event0")
    @Consumes({MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_XML})
    public RestConcreteResult process()
    {
        logger.info("************************************** process has been processed");
        RestConcreteResult result = new RestConcreteResult("test ::: ");
        return result;
    }

}

的pom.xml

...
    <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            </dependency>
        </dependencies>

1 个答案:

答案 0 :(得分:4)

我得到了同样的错误。它是由对旧版本的javax.ws.rs的依赖引起的:

javax.ws.rs;version="[1.1,2)",
javax.ws.rs.core;version="[1.1,2)",

https://issues.apache.org/jira/browse/CXF-5654状态CXF 3.x需要java rs api 2.0。所以我明确地补充说:

javax.ws.rs;version="[2.0,3)",
javax.ws.rs.core;version="[2.0,3)",

在Maven pom.xml中:

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <executions>
                <execution>
                    <id>Create OSGi bundle</id>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                    <configuration>
                        <instructions>
                            <Import-Package>
                                META-INF.cxf,
                                org.apache.cxf.bus.spring,
                                javax.ws.rs;version="[2.0,3)",
                                javax.ws.rs.core;version="[2.0,3)",
                                *
                            </Import-Package>
                        </instructions>
                    </configuration>
                </execution>
            </executions>
        </plugin>