【问题标题】:deploying OSGi project as Webstart using command line tools使用命令行工具将 OSGi 项目部署为 Webstart
【发布时间】:2011-06-29 11:15:16
【问题描述】:

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

我找到了instructions to export a set of OSGi plugins from eclipse。但是很难找到在没有 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 @987654322@),似乎下载了应用程序的 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)

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

【问题讨论】:

    标签: command-line ant build-automation osgi java-web-start


    【解决方案1】:

    我遇到了同样的问题。我通过在包装器 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>
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 或扩展 ant 构建,将 Ivy 与存储库一起用作 OBR(OSGi 捆绑存储库,例如 felix.apache.org/site/apache-felix-osgi-bundle-repository.html)。假设您已经看过 toedter.com/blog/?p=45 之类的帖子
      • earcam,你链接的博客和我第一个链接的内容一样。
      • 嗨 amarillion,看起来您的问题可能已经在 felix 邮件列表上的 Richard S. Hall 的帮助下得到了解决。希望现在/很快一切正常。
      【解决方案3】:

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

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

      【讨论】:

      • 我正在尝试 jbundle,但我遇到了完全不同的问题。出于某种原因,它无法解决在 eclipse 环境中正常工作的某些依赖项。例如,如果我从 felix shell:repos add http://www.bigcat.unimaas.nl/~martina/repository/repository.xml deploy 'org.pathvisio.desktop' 执行此操作,我会得到一长串依赖问题。
      【解决方案4】:

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

      【讨论】:

        猜你喜欢
        • 2019-08-20
        • 2012-09-28
        • 2019-07-08
        • 1970-01-01
        • 2013-03-04
        • 2015-05-13
        • 2018-10-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多