繁体   English   中英

OSGi REST服务无法正常运行(BND工具)

[英]OSGi REST service is not working (bnd tool)

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

这是一条错误消息

! 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! 

这是实现

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";
    }

}

这是一个激活器类

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,现在我无法同时满足它们。

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

  1. org.apache.felix.http.servlet-api替换javax.servlet捆绑包。 它包含相应版本的javax.servlet包。
  2. 还要添加jackson-jaxrs捆绑包

这两个捆绑软件也可以在“ Amdatu Dependencies”存储库中找到。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM