启动 OSGi 包

发布于 2024-09-14 04:15:47 字数 159 浏览 9 评论 0原文

我尝试在 Eclipse 中运行 OSGi 插件。它是空包,但 Eclipse 总是向我发送错误 有我的控制台消息 http://pastebin.com/dqQfpQhd 怎么了?

I try to run OSGi plug in in Eclipse. It is empty bundle, but eclipse always send me errors
There are my console messages
http://pastebin.com/dqQfpQhd
What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

甜尕妞 2024-09-21 04:15:48

问题是默认目标包含许多与您的包无关的包 - 当所有错误消息完成后输入命令 ss 将列出它们。

您要做的如下:

  1. 在 Eclipse 中,转到 Preferences >插件开发>目标平台
  2. 创建一个新的空目标定义
  3. 在“位置”选项卡中,添加一个只包含 Equinox 捆绑包的目录(您可以从 Eclipse 安装的插件目录中复制该捆绑包,该 jar 的名称类似于 org.eclipse.osgi_3.7.0)。 v20110613.jar)
  4. 确保新目标处于活动状态并尝试再次运行您的捆绑包

The problem is that the default target includes many bundles that have nothing to do with your bundle -- typing the command ss when all the error messages have finished will list them.

Here's what you do:

  1. In Eclipse, go to Preferences > Plug-in Development > Target Platform
  2. Create a new empty target definition
  3. In the Locations tab, add a directory containing nothing but the Equinox bundle (which you can copy from the plugins directory of your Eclipse installation, the jar is named something like org.eclipse.osgi_3.7.0.v20110613.jar)
  4. Make sure the new target is active and try running your bundle again
无声静候 2024-09-21 04:15:48

我一整天都在“工作台尚未创建”中挣扎了很多。

但我通过以下步骤得到了解决方案。-

  1. 转到运行配置 ->删除所有目标平台 jar。
  2. 单击添加所需的捆绑包。
  3. 检查 org.apache.felix.gogo.runtime、org.apache.felix.gogo.shell、org.eclipse.eqinox.console、org.eclipse.osgi 和您的 jar 文件。
  4. 最后也是重要的一步。前往设置-> 选中“启动前清除配置区域”复选框。
  5. 现在运行 OSGi 应用程序。
  6. 如果它对你有用,就像它对我有用一样,请尽情享受。

谢谢

I struggled a lot for “Workbench has not been created yet” the complete day.

But I got the solution by the following steps.-

  1. Go to the Run configuration -> Remove all the target platform jars.
  2. Click on add required bundles.
  3. Check the org.apache.felix.gogo.runtime, org.apache.felix.gogo.shell, org.eclipse.eqinox.console, org.eclipse.osgi and your jar file.
  4. The last and important step. Go to Setting-> check the checkbox of "Clear the configuratation area before launching".
  5. Run the OSGi application now.
  6. Enjoy if it works for you as it worked for me.

Thanks

挽容 2024-09-21 04:15:48

这是主要问题:

java.lang.IllegalStateException:工作台尚未创建。

您正在使用工作台中或与工作台相关的方法/对象,而工作台本身尚未创建。也许您可以延迟捆绑包的激活或从捆绑包的激活/初始化部分中删除“工作台”依赖项。


哎呀,回到开头。日志的最后一行包含“Hello World”——这是您的包的预期输出吗?也许不是您的包导致输出上出现错误和警告。我也看到了一些“mylin”和其他东西。如果可能,请在您的系统中添加另一个全新安装的 eclipse(无需额外的捆绑包/插件),并在该环境中尝试该捆绑包。


来自 关于 eclipsezone 的好文章

当有人尝试使用 java -classpath .... 针对 OSGi 包运行 Java 应用程序时,通常会出现这种情况。这实际上意味着工作台插件尚未启动,因此调用 getWorkbench() 失败。这本质上是一个竞争条件,可以通过表达对该捆绑包的显式依赖或将该捆绑包提升到 比工作台更高的启动级别。通常看不到,但如果是的话,那就是正在发生的事情。

你自己的包的超类是什么?因为这可能会引入对工作台的依赖。

并且 - 如何从 Eclipse 中“启动”捆绑包,或者将其打包并放入 Eclipse 插件文件夹中?这也可能会有所作为。

This is the main problem:

java.lang.IllegalStateException: Workbench has not been created yet.

You're using methods/objects from the workbench or related to the workbench while the workbench itself has not been created yet. Maybe you can delay the activation of the bundle or remove 'workbench' dependencies from the activation/initialisation part of the bundle.


Yikes, back to the beginning. The last line of the log containes a 'Hello World' - is this the expected output from your bundle? Maybe it's not your bundle that causes the errors and warnings on the output. I see some 'mylin' and other stuff too. If possible, add another clean installation of eclipse (no additional bundles/plugins) to your system and try the bundle in that environment.


From a good article on eclipsezone:

This usually comes when someone tries to run a Java application against an OSGi bundle with java -classpath .... . It really means that the workbench plug-in hasn't started yet, and so calls to getWorkbench() fail. This is essentially a race condition, and can be solved by either expressing an explicit dependency on that bundle or bumping up that bundle to a higher start level than the workbench. Generally not seen, but if it is, that's what's happening.

What's the superclass of your own bundle? Because that could introduce a dependency on the workbench.

And - how do 'start' the bundle, from within eclipse or hav you jar'ed it up and put it in the eclipse plugin folder? That could make a difference too.

暗恋未遂 2024-09-21 04:15:48

这些错误都与您的捆绑包无关。正如您从“Hello World”输出中看到的,您的包启动得很好。

我相信您以错误的方式启动 Eclipse,可能急切地激活所有捆绑包。 Eclipse 需要以“延迟激活”模式启动大多数工作台包。

  1. 请指定您如何启动 Eclipse。您是否将 -console 添加到 eclipse.ini 文件中?
  2. 当您不尝试使用自己的捆绑包时是否会出现此问题?
  3. 您如何安装和激活自己的捆绑包?
  4. 请粘贴以下文件:
    • 您自己的捆绑包中的 MANIFEST.MF
    • config.ini 来自 ECLIPSE_HOME/configuration
    • eclipse.ini 来自 ECLIPSE_HOME

None of those errors have anything to do with your bundle. As you can see from the "Hello World" output, your bundle is starting just fine.

I believe you are launching Eclipse in the wrong way, probably eagerly activating all the bundles. Eclipse needs to start with most workbench bundles in "lazy activation" mode.

  1. Please specify how you are launching Eclipse. Did you add -console to the eclipse.ini file?
  2. Does this problem occur when you do NOT try to use your own bundle?
  3. How are you installing and activating your own bundle?
  4. Please paste the following files:
    • The MANIFEST.MF from your own bundle
    • config.ini from ECLIPSE_HOME/configuration
    • eclipse.ini from ECLIPSE_HOME
呆橘 2024-09-21 04:15:48

首先检查空插件的依赖关系。可能您缺少添加一个插件,该插件在运行时未加载。

如果您的插件有依赖项,请检查使用的插件版本。

您在插件中定义了哪个 Java 版本?它比您在运行时使用的版本更高吗?

你的插件加载DLL了吗?如果是,请检查运行时是否可以找到该DLL。

编辑:

#
工作台尚未创建。
#
在 org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
#
在 org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin.start(MonitorUiPlugin.java:145)

您在 Activator 的 start 方法中定义了什么?
看来您正在使用尚未创建的工作台。

First check the dependencies of the empty plugin. May be you are missing to add a plugin, whcih is not loaded at runtime.

If you have dependencies in your plugin, check hich version of the plugins are used.

Which Java version you have defined in your plugin? Is it higher, than the version you are using at runtime?

Is your plugin loading DLLs? if so, check whether the DLL can be found at runtime.

Edit:

#
Workbench has not been created yet.
#
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
#
at org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin.start(MonitorUiPlugin.java:145)

What did you define in the start method of the Activator?
It sems, that you are using the workbench which is not created yet.

简美 2024-09-21 04:15:48

在运行你的包之前尝试这样做:

if(!PlatformUI.isWorkbenchRunning()) {
    PlatformUI.createAndRunWorkbench(PlatformUI.createDisplay(), new WorkbenchAdvisor() {...}); 
}

Try to do this before running your bundle:

if(!PlatformUI.isWorkbenchRunning()) {
    PlatformUI.createAndRunWorkbench(PlatformUI.createDisplay(), new WorkbenchAdvisor() {...}); 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文