使用命令行工具将 OSGi 项目部署为 Webstart

发布于 2024-11-17 22:55:07 字数 2982 浏览 0 评论 0原文

如何使用命令行工具创建可以通过 Java Webstart 分发的模块化 OSGi 项目?

我找到了从 eclipse 导出一组 OSGi 插件的说明。但是,很难找到在没有 Eclipse 帮助的情况下执行此操作的说明。我想使用 ant 构建脚本和/或其他命令行工具来完成此操作。

这是我到目前为止所得到的。使用 ant,所有插件包都被复制到一个目录并签名。之后,我创建了一个名为wrapper.jnlp 的jnlp 文件。

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="wrapper.jnlp">
    <information>
        <title>My app</title>
        <vendor>Me</vendor>
        <offline-allowed/>
    </information>
    <resources>
        <j2se version="1.5+" java-vm-args="-Xmx512M"/>
        <jar href="org.eclipse.equinox.launcher.jar"/>
        <extension name="Wrapper feature" href="myprogram.jnlp"/>
    </resources>
    <application-desc main-class="org.eclipse.equinox.launcher.WebStartMain"/>
    <security>
         <all-permissions/>
    </security>
</jnlp>

我创建了第二个名为myprogram.jnlp 的jnlp 文件。

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="myprogram.jnlp">
    <information>
        <title>My app</title>
        <offline-allowed/>
    </information>
    <resources>
         <j2se version="1.5+" java-vm-args="-Xmx512M"/>
         <jar href="myapp.jar"/>
         <jar href="derby.jar"/>
         <jar href="commons-math-2.0.jar"/>
             ...omitting a dozen more jar files...
    </resources>
    <application-desc main-class="myprogram.Main"/>
    <security>
         <all-permissions/>
    </security>
</jnlp>

当我部署并尝试启动它时(从命令行: javaws http://localhost/webstart/wrapper .jnlp),应用程序的 jar 文件似乎已下载。然后我在日志文件中收到以下错误:

!SESSION Wed Jun 29 13:43:52 CEST 2011 -----------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2011-06-29 13:43:52.448
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:411)
    at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartMain.java:78)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
    at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:590)
    at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)

知道我做错了什么吗?接下来我该看哪里?

How do I create a modular OSGi project that can be distributed with Java Webstart, using command line tools?

I've found instructions to export a set of OSGi plugins from eclipse. But instructions for doing so without the help of eclipse are hard to find. I would like to do this using ant build scripts and / or other command line tools.

Here is what I've got so far. Using ant, all the plug-in bundles are copied to a directory and signed. After that, I've created a jnlp file named wrapper.jnlp

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="wrapper.jnlp">
    <information>
        <title>My app</title>
        <vendor>Me</vendor>
        <offline-allowed/>
    </information>
    <resources>
        <j2se version="1.5+" java-vm-args="-Xmx512M"/>
        <jar href="org.eclipse.equinox.launcher.jar"/>
        <extension name="Wrapper feature" href="myprogram.jnlp"/>
    </resources>
    <application-desc main-class="org.eclipse.equinox.launcher.WebStartMain"/>
    <security>
         <all-permissions/>
    </security>
</jnlp>

I've created a second jnlp file named myprogram.jnlp.

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="myprogram.jnlp">
    <information>
        <title>My app</title>
        <offline-allowed/>
    </information>
    <resources>
         <j2se version="1.5+" java-vm-args="-Xmx512M"/>
         <jar href="myapp.jar"/>
         <jar href="derby.jar"/>
         <jar href="commons-math-2.0.jar"/>
             ...omitting a dozen more jar files...
    </resources>
    <application-desc main-class="myprogram.Main"/>
    <security>
         <all-permissions/>
    </security>
</jnlp>

When I deploy and try to start it (from the command line: javaws http://localhost/webstart/wrapper.jnlp), the jar files of the application appear to be downloaded. Then I get the following error in a log file:

!SESSION Wed Jun 29 13:43:52 CEST 2011 -----------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2011-06-29 13:43:52.448
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:411)
    at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartMain.java:78)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
    at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:590)
    at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)

Any idea what I'm doing wrong? Where should I look next?

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

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

发布评论

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

评论(4

心清如水 2024-11-24 22:55:07

我有同样的问题。我通过在包装器 jnlp 中指定以下内容解决了这个问题:

    <resources>
        <!-- Reference to the launcher jar. The version segment must be updated to the version being used-->
        <jar href="plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" />
        <!-- Reference to the osgi jar. The version segment must be updated to the version being used-->
        <jar href="plugins/org.eclipse.osgi_3.7.0.v20110613.jar" />

        ...

    </resources>

I had the same issue. I solved it by specifying the following in my wrapper jnlp:

    <resources>
        <!-- Reference to the launcher jar. The version segment must be updated to the version being used-->
        <jar href="plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" />
        <!-- Reference to the osgi jar. The version segment must be updated to the version being used-->
        <jar href="plugins/org.eclipse.osgi_3.7.0.v20110613.jar" />

        ...

    </resources>
夜雨飘雪 2024-11-24 22:55:07

我相信您可能想要切换方式并使用您的代码和所有依赖项创建一个 P2 存储库,然后让一个简单的 p2-installer 从那里提取依赖项(绕过 WebStart)并启动您的应用程序。

I believe you might want to switch gears and create a P2 repository with your code and all dependencies, then have a bare-bones p2-installer pull the dependencies from there (bypassing WebStart) and start your application.

翻身的咸鱼 2024-11-24 22:55:07

看看这个 http://www.jbundle.org/osgi-webstart/ ”使用此 servlet 将您的 OSGi 应用程序部署到 Web 客户端。”

虽然它是文档中的一个 Maven 插件,但看起来您可以在没有 Maven 项目的情况下运行它。

Have a look at this http://www.jbundle.org/osgi-webstart/ "Use this servlet to deploy your OSGi apps to a web client."

Though it's a maven plugin from the documentation it looks like you can run it without a maven project.

转身泪倾城 2024-11-24 22:55:07

根据消息来源,您的问题是由于未能在类路径上找到 org.eclipse.osgi 包引起的。确保正确引用该捆绑包并且具有正确的清单。

According to the sources, your problem is caused by failing to find org.eclipse.osgi bundle on the classpath. Make sure that the bundle is referenced properly and that it has correct manifest.

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