草庐IT

java - 由于 OSGi 包依赖性问题,无法启动 RCP 应用程序

coder 2024-04-02 原文

我们在我们的 RCP 应用程序中同时使用 spring-webspring-websocket,它们都通过 p2-maven-plugin 转换为 bundle。 .下面是我们应用程序的 MANIFEST.MF 文件。

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Todo
Bundle-SymbolicName: com.example.e4.rcp.todo;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EXAMPLE
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.apache.commons.logging;bundle-version="1.2.0",
 org.springframework.spring-aop;bundle-version="4.3.3",
 org.springframework.spring-beans;bundle-version="4.3.3",
 org.springframework.spring-context;bundle-version="4.3.3",
 org.springframework.spring-core;bundle-version="4.3.3",
 org.springframework.spring-expression;bundle-version="4.3.3",
 org.springframework.spring-web;bundle-version="4.3.3",
 org.eclipse.e4.ui.css.swt;bundle-version="0.12.0",
 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
 org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.2.0",
 org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.13.0",
 org.eclipse.e4.ui.workbench.swt;bundle-version="0.13.0",
 org.eclipse.swt;bundle-version="3.104.1",
 org.eclipse.e4.ui.di;bundle-version="1.1.0",
 org.eclipse.e4.core.services;bundle-version="2.0.100",
 org.eclipse.osgi.services;bundle-version="3.5.100",
 org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
 org.springframework.spring-websocket;bundle-version="4.3.2",
 org.springframework.spring-messaging;bundle-version="4.3.2",
 javax.inject;bundle-version="1.0.0",
 javax.annotation;bundle-version="1.2.0",
 org.apache.tomcat.embed.tomcat-embed-core;bundle-version="8.5.4",
 org.apache.tomcat.embed.tomcat-embed-websocket;bundle-version="8.5.4"

当我启动应用程序时,它会弹出以下错误:

 !SESSION 2016-11-10 09:48:03.750 -----------------------------------------------
 eclipse.buildId=unknown
 java.version=1.8.0_101
 java.vendor=Oracle Corporation
 BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
 Framework arguments:  -product com.example.e4.rcp.todo.product clearPersistedState
 Command-line arguments:  -product com.example.e4.rcp.todo.product -data > :\Users\wangzen\Console_prototype/../runtime-todo.product -dev > ile:C:/Users/wangzen/Console_prototype/.metadata/.plugins/org.eclipse.pde.core/to> o.product/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog > clearPersistedState

 !ENTRY org.eclipse.equinox.app 0 0 2016-11-10 09:48:04.703
 !MESSAGE Product com.example.e4.rcp.todo.product could not be found.

 !ENTRY com.example.e4.rcp.todo 2 0 2016-11-10 09:48:04.786
 !MESSAGE Could not resolve module: com.example.e4.rcp.todo [491]
   Bundle was not resolved because of a uses contraint violation.
   org.osgi.service.resolver.ResolutionException: Uses constraint violation. nable>  to resolve resource com.example.e4.rcp.todo [osgi.identity;>  sgi.identity="com.example.e4.rcp.todo"; type="osgi.bundle";>  ersion:Version="1.0.0.qualifier"; singleton:="true"] because it is exposed to>  ackage 'javax.servlet' from resources rg.apache.tomcat.embed.tomcat-embed-core>  [osgi.identity; type="osgi.bundle"; ersion:Version="8.5.4";>  sgi.identity="org.apache.tomcat.embed.tomcat-embed-core"] and javax.servlet>  osgi.identity; type="osgi.bundle"; version:Version="3.1.0.v201410161800";>  sgi.identity="javax.servlet"] via two dependency chains.

 Chain 1:
   com.example.e4.rcp.todo [osgi.identity; sgi.identity="com.example.e4.rcp.todo";>  type="osgi.bundle"; ersion:Version="1.0.0.qualifier"; singleton:="true"]
     require:>  &(osgi.wiring.bundle=org.apache.tomcat.embed.tomcat-embed-core)(bundle-versio> >=8.5.4))
      |
     provide: osgi.wiring.bundle: org.apache.tomcat.embed.tomcat-embed-core
   org.apache.tomcat.embed.tomcat-embed-core [osgi.identity; ype="osgi.bundle";>  version:Version="8.5.4";>  sgi.identity="org.apache.tomcat.embed.tomcat-embed-core"]

 Chain 2:
   com.example.e4.rcp.todo [osgi.identity; sgi.identity="com.example.e4.rcp.todo";>  type="osgi.bundle"; ersion:Version="1.0.0.qualifier"; singleton:="true"]
     require:>  &(osgi.wiring.bundle=org.springframework.spring-web)(bundle-version>=4.3.3))
      |
     provide: osgi.wiring.bundle; bundle-version:Version="4.3.3.RELEASE";>  sgi.wiring.bundle="org.springframework.spring-web"
   org.springframework.spring-web [osgi.identity; type="osgi.bundle";>  ersion:Version="4.3.3.RELEASE"; osgi.identity="org.springframework.spring-web"]
     import: (osgi.wiring.package=javax.servlet)
      |
     export: osgi.wiring.package: javax.servlet
   javax.servlet [osgi.identity; type="osgi.bundle";>  ersion:Version="3.1.0.v201410161800"; osgi.identity="javax.servlet"]

 !ENTRY org.eclipse.osgi 4 0 2016-11-10 09:48:04.787
 !MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
    at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
    at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
gogo: InterruptedException: sleep interrupted
java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at org.apache.felix.gogo.shell.Activator.run(Activator.java:72)
    at java.lang.Thread.run(Thread.java:745)
An error has occurred. See the log file
C:\Users\wangzen\runtime-todo.product\.metadata\.log.

看来问题是由 org.apache.tomcat.embed.tomcat-embed-coreorg.springframework.spring-web 都具有依赖链引起的javax.servlet。然而,在我删除 tomcat 库后,它告诉我另一个错误如下:

java.lang.NoClassDefFoundError: org/apache/tomcat/InstanceManagerBindings
    at org.apache.tomcat.websocket.WsSession.<init>(WsSession.java:187)
    at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:403)
    at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)
    at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.InstanceManagerBindings cannot be found by org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

更新

我尝试过的:

  • 通过检查 Eclipse 提供的 Plug-in Dependencies 工具的依赖关系,如下截图所示,我发现 org.apache.tomcat.embed.tomcat-embed-coreorg.apache.tomcat.embed.tomcat-embed-websocket 对于我的应用程序可能不是必需的,因此我删除了这两个包并重新启动了我的应用程序。

但是又出现如下错误信息:

java.lang.NoClassDefFoundError: org/apache/tomcat/InstanceManagerBindings
    at org.apache.tomcat.websocket.WsSession.<init>(WsSession.java:187)
    at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:403)
    at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)
    at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.InstanceManagerBindings cannot be found by org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more
  • 在导入这些第三方库时,我还尝试用 Import-Package 替换 Require-Bundle,如下所示:

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Todo
    Bundle-SymbolicName: com.example.e4.rcp.todo;singleton:=true
    Bundle-Version: 1.0.0.qualifier
    Bundle-Vendor: EXAMPLE
    Bundle-RequiredExecutionEnvironment: JavaSE-1.8
    Require-Bundle: org.eclipse.e4.ui.css.swt;bundle-version="0.12.0",
     org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
     org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.2.0",
     org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.13.0",
     org.eclipse.e4.ui.workbench.swt;bundle-version="0.13.0",
     org.eclipse.swt;bundle-version="3.104.1",
     org.eclipse.e4.ui.di;bundle-version="1.1.0",
     org.eclipse.e4.core.services;bundle-version="2.0.100",
     org.eclipse.osgi.services;bundle-version="3.5.100",
     org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
     javax.inject;bundle-version="1.0.0",
     javax.annotation;bundle-version="1.2.0"
    Import-Package: org.apache.tomcat,
     org.springframework.http,
     org.springframework.http.client,
     org.springframework.http.client.support,
     org.springframework.messaging.converter,
     org.springframework.messaging.simp.stomp,
     org.springframework.scheduling,
     org.springframework.scheduling.concurrent,
     org.springframework.util,
     org.springframework.web.client,
     org.springframework.web.socket.client,
     org.springframework.web.socket.client.standard,
     org.springframework.web.socket.messaging,
     org.springframework.web.socket.sockjs.client
    

但是它仍然弹出相同的错误通知我 org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4 找不到 org.apache.tomcat.InstanceManagerBindings

最佳答案

您在这里面临着几个问题。第一个是你到处使用 require bundle。 require bundle 的问题在于你总是会接触到一个 bundle 提供的所有包。这将增加使用链约束违规的可能性。您应该尝试改用 Import-Package。

另一个问题是 spring 不再支持 OSGi。因此,在 OSGi 中使用 spring 库很可能会产生问题,因为它们根本不在 OSGi 中测试代码。

如果您需要 websocket 支持,那么更好的选择可能是 pax web .它与 tomcat 或 jetty 一起运行,并以 OSGi 兼容的方式包装它们。

不幸的是,eclipse 中没有 pax-web 或 plain jetty 的示例。要查看您需要什么包,您可以启动 apache karaf 并安装 http 功能。然后您可以查看它安装的 bundle 并在 eclipse rcp 中使用它们。

关于java - 由于 OSGi 包依赖性问题,无法启动 RCP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40519309/

有关java - 由于 OSGi 包依赖性问题,无法启动 RCP 应用程序的更多相关文章

  1. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  2. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  3. ruby-on-rails - Rails 应用程序之间的通信 - 2

    我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此

  4. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  5. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  6. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  7. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  8. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  9. ruby-on-rails - 启动 Rails 服务器时 ImageMagick 的警告 - 2

    最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru

  10. ruby-on-rails - 在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本? - 2

    我正在尝试修改当前依赖于定义为activeresource的gem:s.add_dependency"activeresource","~>3.0"为了让gem与Rails4一起工作,我需要扩展依赖关系以与activeresource的版本3或4一起工作。我不想简单地添加以下内容,因为它可能会在以后引起问题:s.add_dependency"activeresource",">=3.0"有没有办法指定可接受版本的列表?~>3.0还是~>4.0? 最佳答案 根据thedocumentation,如果你想要3到4之间的所有版本,你可以这

随机推荐