使用java web start启动eclipse应用程序会生成java.lang.ClassNotFoundException:org.eclipse.swt.SWTError

时间:2012-05-28 14:10:55

标签: java eclipse swt rcp java-web-start

我有一个Eclipse应用程序,为此我创建了用于生成jnlp文件的功能。 我用maven tycho构建了应用程序,用于体系结构x86和x86_64。

当我尝试为应用程序启动jnlp时,我看到所有资源都已下载,但应用程序无法启动。如果我尝试在broswer中打开它,它就会启动。我检查了第一个案例的日志,我得到了以下内容:

eclipse.buildId=unknown
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -clientno=01 -StartupLogo=false -mode=3 -sessionid=7110AAD90803F34A9B01CD66A676E0ED.ASES01 -ServletDir=/SES/ -Port=8080 -host=172.20.224.138 -auth=tftttttttttt -Lang=de_DE -user=taris -Protocol=http
Command-line arguments:  -clientno=01 -StartupLogo=false -mode=3 -sessionid=7110AAD90803F34A9B01CD66A676E0ED.ASES01 -ServletDir=/SES/ -Port=8080 -host=172.20.224.138 -auth=tftttttttttt -Lang=de_DE -user=taris -Protocol=http

!ENTRY org.eclipse.osgi 4 0 2012-05-28 15:56:46.999
!MESSAGE An error occurred while automatically activating bundle org.eclipse.ui.workbench (20).
!STACK 0
org.osgi.framework.BundleException: The activator org.eclipse.ui.internal.WorkbenchPlugin for bundle org.eclipse.ui.workbench is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:268)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:463)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:473)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass
[....]

Caused by: java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:166)
    ... 78 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 84 more

以下是生成资源的pom的一部分:

<plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho-version}</version>
            <configuration>
                <resolver>p2</resolver>
                                    <ignoreTychoRepositories>true</ignoreTychoRepositories>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>

我确实检查过资源是否在jnlp文件中引用:

<resources os="Windows" arch="x86">
<jar href="plugins/org.eclipse.swt.win32.win32.x86_3.7.2.v3740f.jar"/>

    

我还检查了缓存并下载了资源。

我无法找到应用程序无法启动Java Web Start的原因,因为在浏览器中直接启动应用程序时没有任何问题。

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

我的应用程序出现了同样的错误。该项目使用buckminster构建,但也适用于x86和x86_64。

您的应用程序确实是通过浏览器启动的,因为这是一个32位应用程序,它将调用您的webstart作为32位应用程序。

通过Windows资源管理器启动应用程序,启动64位应用程序,这会遇到麻烦。

以下是适合我的解决方案:
编辑包含功能的jnlp文件:
修改(原始的jnlp文件,它不起作用)

...
</resources>
<resources os="Windows" arch="x86">
    <jar href="plugins/org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar"/>
    <jar href="plugins/org.eclipse.core.filesystem.win32.x86_1.1.300.v20110423-0524.jar"/>
    <jar href="plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502.jar"/>
</resources>
<resources os="Windows" arch="x86_64">
    <jar href="plugins/org.eclipse.core.filesystem.win32.x86_64_1.1.300.v20110423-0524.jar"/>
    <jar href="plugins/org.eclipse.swt.win32.win32.x86_64_3.7.0.v3735b.jar"/>
    <jar href="plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502.jar"/>
</resources>

into(新的jnlp文件,应该可以工作)

    ...
<resources os="Windows" arch="x86">
    <jar href="plugins/org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar"/>
    <jar href="plugins/org.eclipse.core.filesystem.win32.x86_1.1.300.v20110423-0524.jar"/>
    <jar href="plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502.jar"/>
<resources os="Windows">
    <jar href="plugins/org.eclipse.core.filesystem.win32.x86_64_1.1.300.v20110423-0524.jar"/>
    <jar href="plugins/org.eclipse.swt.win32.win32.x86_64_3.7.0.v3735b.jar"/>
    <jar href="plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502.jar"/>
</resources>

换句话说:删除arch =“x86_64”过滤器。

我认为这是昼夜平分点发射器的错误。但它的真正原因对我来说是个秘密。

P.S:仅为org.eclipse.swt.win32.win32.x86_64捆绑包删除arch-filter也适用。
P.P.S:我在这里找到了一个类似的问题:http://www.eclipse.org/forums/index.php/t/314656/