首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OSGi REST服务无法工作(bnd工具)

OSGi REST服务无法工作(bnd工具)
EN

Stack Overflow用户
提问于 2014-08-11 06:11:46
回答 1查看 1.6K关注 0票数 0

我正在编写一个REST服务,根据Amdatu指南,它非常简单,但是它抛给我的是一个错误,我已经添加了所有的依赖项,但仍然缺少需求错误。

这里是一个错误消息

代码语言:javascript
复制
! could not resolve the bundles
! Failed to start bundle org.apache.felix.http.whiteboard-2.3.0, exception Unresolved constraint in bundle org.apache.felix.http.whiteboard [13]: Unable to resolve 13.0: missing requirement [13.0] osgi.wiring.package; (&(osgi.wiring.package=javax.servlet)(version>=3.0.0)(!(version>=4.0.0)))
! Failed to start bundle org.amdatu.web.rest.wink-1.0.8, exception Unresolved constraint in bundle org.amdatu.web.rest.wink [14]: Unable to resolve 14.0: missing requirement [14.0] osgi.wiring.package; (&(osgi.wiring.package=org.codehaus.jackson.jaxrs)(version>=1.9.0)(!(version>=2.0.0)))
! Failed to start bundle org.apache.felix.http.jetty-2.3.0, exception Unresolved constraint in bundle org.apache.felix.http.jetty [15]: Unable to resolve 15.0: missing requirement [15.0] osgi.wiring.package; (&(osgi.wiring.package=javax.servlet)(version>=3.0.0)(!(version>=4.0.0)))
____________________________
Welcome to Apache Felix Gogo

g! 

这里是实现

代码语言:javascript
复制
package web.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("hellorest")
public class HelloWorldResource {
    @GET
    @Produces(MediaType.TEXT_HTML)
    public String say_hello() {
        return "hello";
    }

}

这里是一个Activator类

代码语言:javascript
复制
package web.rest;

import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;

public class Activator extends DependencyActivatorBase{

    @Override
    public void destroy(BundleContext arg0, DependencyManager arg1)
            throws Exception {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void init(BundleContext arg0, DependencyManager manager)
            throws Exception {
        manager.add(createComponent()
                .setInterface(Object.class.getName(),null)
                .setImplementation(HelloWorldResource.class));
    }

}

我已经将这些添加到构建依赖项

--这些是运行依赖项

如果您要求我将Servlet包更改为3.0,我将回答其他一些服务要求,Servlet版本必须小于3.0,现在我不能同时满足它们。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-12 19:45:56

问题在于您的“运行包”配置:

  1. org.apache.felix.http.servlet-api.替换javax.servlet包它在适当的版本中包含javax.servlet包。
  2. 添加jackson-jaxrs

这两个包也都可以在“Amdatu依赖项”存储库中获得。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25236831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档