Servlets Karaf和EclipseEquinox OSGI服务

Servlets Karaf和EclipseEquinox OSGI服务,servlets,osgi,equinox,karaf,Servlets,Osgi,Equinox,Karaf,在一系列关于Java webframeworks的博客中,它应该在OSGI中发挥良好的作用, 我正在仔细观察卡拉夫。我的测试用例非常简单,部署一个Servlet 在卡拉夫。OSGI有不同的HTTPService实现,我正在尝试Equinox实现(org.eclipse.OSGI.services) 我的捆绑包在没有HTTPService依赖项的情况下可以很好地加载,但是当我为HTTPService[3]、Servlet添加依赖项并尝试安装功能[1]时,我遇到了麻烦[2] 注: HTTP服务本身

在一系列关于Java webframeworks的博客中,它应该在OSGI中发挥良好的作用, 我正在仔细观察卡拉夫。我的测试用例非常简单,部署一个Servlet 在卡拉夫。OSGI有不同的HTTPService实现,我正在尝试Equinox实现(org.eclipse.OSGI.services)

我的捆绑包在没有HTTPService依赖项的情况下可以很好地加载,但是当我为HTTPService[3]、Servlet添加依赖项并尝试安装功能[1]时,我遇到了麻烦[2]

注:

  • HTTP服务本身是使用OSGI DS服务安装的[3]
  • Karaf配置为使用Equinox OSGI impl
所以抱怨是关于白羊座蓝图的,但在我试图安装的包中,我并不依赖它

欢迎各界人士提供意见

谢谢,, 克里斯托夫·布希尔

[1] 名为oss2的Karaf功能

<?xml version="1.0" encoding="UTF-8"?>
<features name="oss2-features" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
  <feature name="oss2" version="1.0.0">
    <bundle>file:///Users/Christophe/Documents/Projects/GIT_netxstudio/plugins/base/com.netxforge.oss2.web/target/com.netxforge.oss2.web-1.0.0-SNAPSHOT.jar</bundle>
    <bundle>file:///Users/Christophe/Documents/Spaces/netxstudio/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/javax.servlet_3.0.0.v201112011016.jar</bundle>
    <bundle>file:///Users/Christophe/Documents/Spaces/netxstudio/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.osgi.services_3.3.100.v20130513-1956.jar</bundle>
    <bundle>file:///Users/Christophe/Documents/Spaces/netxstudio/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.osgi_3.9.1.v20140110-1610.jar</bundle>
    <bundle>file:///Users/Christophe/Documents/Spaces/netxstudio/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.equinox.transforms.hook_1.0.401.v20130327-1442.jar</bundle>
    <bundle>file:///Users/Christophe/Documents/Spaces/netxstudio/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.equinox.weaving.hook_1.0.200.v20130327-1442.jar</bundle>
  </feature>
</features>
[3] 服务

@Component
public class WebDude{

    private HttpService httpService;

    @Activate
    public void activate() {
        try {
            httpService.registerServlet("/dudeme", new WebDudeServlet(), null, null);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    @Reference
    public void setHTTPService(HttpService httpService) {
        this.httpService = httpService;
    }

    class WebDudeServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;

        @Override
          protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.getWriter().write("I am dude");      
          }
    }
}

您正在安装org.eclipse.osgi_3.9.1.v20140110-1610.jar,它本身就是一个osgi框架。永远不要将框架捆绑包安装到现有框架中

相反,将karaf切换到equinox。在etc/config.properties集合中:

karaf.framework=equinox
然后将上述包从功能文件中删除。您甚至可以通过使用HTTPS服务和DS的karaf功能来缩小该功能:

功能:安装scr http


因此,也许之后您可以直接安装自己的捆绑包。

正如我在问题中所述,Karaf已经为Equinox配置好了。我还认为安装org.eclipse.osgi可能会有问题,所以我尝试将其忽略,但我得到了完全相同的错误。关于功能:安装scr http。我可以这样做,但整个目的是让它与equinox HTTPService实现一起工作。有人这样做过吗?我最初的问题是,如何阅读和理解错误消息。与Apache Aries有什么关系?该消息意味着无法解析包org.Apache.Aries.blueprint.core,因为您安装的包引入了相同包的冲突导出。这是因为blueprint捆绑包已经安装,karaf尝试使用功能安装后可用的新捆绑包再次解决此问题。
karaf.framework=equinox