Launching eclipse application with java web start

2019-09-17 04:14发布

问题:

I have an Eclipse application, for which I created the feature for generating the jnlp file. I built the application with maven tycho, for architectures x86 and x86_64.

When I try to start the jnlp for the application, I see that all the resources are downloaded, but the application does not start. If I try to open it in a broswer, it starts. I checked the logs for the first case and I got the following:

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

Here is the part of the pom for generating the resources:

<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>

I did check that the resources are referenced in the jnlp file:

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

I also checked the cache and the resources are downloaded.

I just can't find a reason for the application not starting with Java web start, when there are no problems with starting it direcly in the browser.

Any help is appreciated!

回答1:

I got the same error for my application. The project was built using buckminster instead, but for x86 and x86_64 too.

Your application does start via the browser, because this is a 32-bit application and the will invoke your webstart as a 32-bit application.

Starting your application via the Windows Explorer, a 64-bit application is started, which runs into trouble.

Here is the solution that worked for me:
Edit your jnlp file containing the features:
Modify (the orginal jnlp file, which does not work)

...
</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 (the new jnlp file, which should work)

    ...
<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>

In other words: remove the arch="x86_64" filter.

I assume this is an error of the equinox launcher. But its real cause stays a secret to me.

P.S: Removing the arch-filter only for the org.eclipse.swt.win32.win32.x86_64 bundle works too.
P.P.S: I found a similar question here: http://www.eclipse.org/forums/index.php/t/314656/