簡體   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