SWT and Equinox product export problems [message #797726] |
Mon, 13 February 2012 21:03 |
abadamcd1 abadamcd1 Messages: 40 Registered: December 2011 |
Member |
|
|
So I'm making a plugin project that uses SWT for the gui and declarative services for loading the gui service up.
My application launches fine with the run configuration I use in eclipse. The gui starts up and we all dance and sing. However, whenever I make a product definition from this runtime config and export it, the gui won't start and the OSGI console throws me NoClassDefFoundError whenever it hits an import for anything in the SWT libraries.
I made a very simple project to demonstrate this behavior. All it does is load up a window with some text in a control. Works fine when I run from the eclipse environment, and then doesn't when I run it after I export
What I've noticed is that when running from eclipse, the platform specific swt bundle fragment shows as resolved. It also tells me that the generic swt bundle has a fragment bundle associate with it. However, the osgi console only shows that it's installed when run from the executable.
Run From Eclipse Environment:
id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
1 ACTIVE org.eclipse.osgi.services_3.2.0.v20090520-1800
2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
4 ACTIVE org.eclipse.swt_3.5.2.v3557f
Fragments=5
5 RESOLVED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
Master=4
6 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
7 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
8 ACTIVE com.mnet.uiTest_1.0.0.qualifier
9 INSTALLED org.eclipse.swt.win32.win32.x86_3.5.2.v3557f
10 INSTALLED org.eclipse.swt.win32.win32.x86_64_3.5.2.v3557f
11 INSTALLED org.eclipse.swt.wpf.win32.x86_3.5.2.v3557f
Run From exported product:
id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
1 ACTIVE com.mnet.uiTest_1.0.0.201202131522
2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
3 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
4 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
5 RESOLVED org.eclipse.osgi.services_3.2.0.v20090520-1800
6 ACTIVE org.eclipse.swt_3.5.2.v3557f
7 INSTALLED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
Here is my product definition:
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product application="org.eclipse.ui.ide.workbench" useFeatures="false" includeLaunchers="true">
<configIni use="default">
</configIni>
<launcherArgs>
<programArgs>-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -console</programArgs>
<vmArgs>-Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dequinox.ds.print=true</vmArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
</launcherArgs>
<launcher name="test">
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
<plugin id="com.mnet.uiTest"/>
<plugin id="org.eclipse.equinox.common"/>
<plugin id="org.eclipse.equinox.ds"/>
<plugin id="org.eclipse.equinox.util"/>
<plugin id="org.eclipse.osgi"/>
<plugin id="org.eclipse.osgi.services"/>
<plugin id="org.eclipse.swt"/>
<plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.wpf.win32.x86" fragment="true"/>
</plugins>
<configurations>
<plugin id="com.mnet.uiTest" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" />
<plugin id="org.eclipse.swt" autoStart="true" startLevel="0" />
</configurations>
</product>
Manifest for ui bundle:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: UiTest
Bundle-SymbolicName: com.mnet.uiTest
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MNET
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/component.xml
Import-Package: org.eclipse.swt,
org.eclipse.swt.widgets
Export-Package: com.mnet.uiTest
Component Definition for ui bundle:
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="no links allowed" activate="startup" deactivate="shutdown" immediate="true" name="com.mnet.uiTest">
<implementation class="com.mnet.uiTest.UITest"/>
<service>
<provide interface="com.mnet.uiTest.UITest"/>
</service>
</scr:component>
GUI Class Code:
package com.mnet.uiTest;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class UITest implements Runnable {
private Display display;
private boolean isRunning;
private Text txtWindow;
@Override
public void run(){
display = new Display();
Shell myShell = new Shell(display);
myShell.setSize(600, 600);
txtWindow = new Text(myShell, SWT.MULTI | SWT.V_SCROLL);
txtWindow.setText("Starting");
txtWindow.setSize(200, 200);
myShell.open();
runDisplayEventQueue();
}
private void runDisplayEventQueue() {
isRunning = true;
while (isRunning && !display.isDisposed())
try {
if (!display.readAndDispatch())
display.sleep();
} catch (Throwable t) {
t.printStackTrace();
}
isRunning = false;
display.dispose();
shutdown();
}
public void startup() {
System.out.println("Starting GUI");
new Thread
(this).start();
}
public void shutdown() {
System.out.println("shutting down gui");
if(isRunning)
display.syncExec( new Runnable() { public void run() { display.dispose();} });
}
}
|
|
|
Re: SWT and Equinox product export problems [message #797734 is a reply to message #797726] |
Mon, 13 February 2012 21:12 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
In the export there's only the linux-swt fragment. On which OS are you
running?
Tom
Am 13.02.12 22:03, schrieb Missing name Mising name:
> So I'm making a plugin project that uses SWT for the gui and declarative
> services for loading the gui service up.
>
> My application launches fine with the run configuration I use in
> eclipse. The gui starts up and we all dance and sing. However,
> whenever I make a product definition from this runtime config and export
> it, the gui won't start and the OSGI console throws me
> NoClassDefFoundError whenever it hits an import for anything in the SWT
> libraries.
>
> I made a very simple project to demonstrate this behavior. All it does
> is load up a window with some text in a control. Works fine when I run
> from the eclipse environment, and then doesn't when I run it after I export
>
> What I've noticed is that when running from eclipse, the platform
> specific swt bundle fragment shows as resolved. It also tells me that
> the generic swt bundle has a fragment bundle associate with it.
> However, the osgi console only shows that it's installed when run from
> the executable.
>
> Run From Eclipse Environment:
>
> id State Bundle
> 0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
> 1 ACTIVE org.eclipse.osgi.services_3.2.0.v20090520-1800
> 2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
> 4 ACTIVE org.eclipse.swt_3.5.2.v3557f
> Fragments=5
> 5 RESOLVED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
> Master=4
> 6 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
> 7 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
> 8 ACTIVE com.mnet.uiTest_1.0.0.qualifier
> 9 INSTALLED org.eclipse.swt.win32.win32.x86_3.5.2.v3557f
> 10 INSTALLED org.eclipse.swt.win32.win32.x86_64_3.5.2.v3557f
> 11 INSTALLED org.eclipse.swt.wpf.win32.x86_3.5.2.v3557f
>
>
> Run From exported product:
> id State Bundle
> 0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
> 1 ACTIVE com.mnet.uiTest_1.0.0.201202131522
> 2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
> 3 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
> 4 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
> 5 RESOLVED org.eclipse.osgi.services_3.2.0.v20090520-1800
> 6 ACTIVE org.eclipse.swt_3.5.2.v3557f
> 7 INSTALLED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
>
>
> Here is my product definition:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?pde version="3.5"?>
>
> <product application="org.eclipse.ui.ide.workbench" useFeatures="false"
> includeLaunchers="true">
>
> <configIni use="default">
> </configIni>
>
> <launcherArgs>
> <programArgs>-os ${target.os} -ws ${target.ws} -arch ${target.arch}
> -nl ${target.nl} -console</programArgs>
> <vmArgs>-Declipse.ignoreApp=true -Dosgi.noShutdown=true
> -Dequinox.ds.print=true</vmArgs>
> <vmArgsMac>-XstartOnFirstThread
> -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
> </launcherArgs>
>
>
> <launcher name="test">
> <solaris/>
> <win useIco="false">
> <bmp/>
> </win>
> </launcher>
>
> <vm>
> </vm>
>
> <plugins>
> <plugin id="com.mnet.uiTest"/>
> <plugin id="org.eclipse.equinox.common"/>
> <plugin id="org.eclipse.equinox.ds"/>
> <plugin id="org.eclipse.equinox.util"/>
> <plugin id="org.eclipse.osgi"/>
> <plugin id="org.eclipse.osgi.services"/>
> <plugin id="org.eclipse.swt"/>
> <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
> <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
> <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
> <plugin id="org.eclipse.swt.wpf.win32.x86" fragment="true"/>
> </plugins>
>
> <configurations>
> <plugin id="com.mnet.uiTest" autoStart="true" startLevel="0" />
> <plugin id="org.eclipse.equinox.common" autoStart="true"
> startLevel="2" />
> <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="0" />
> <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" />
> <plugin id="org.eclipse.swt" autoStart="true" startLevel="0" />
> </configurations>
>
> </product>
>
>
> Manifest for ui bundle:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: UiTest
> Bundle-SymbolicName: com.mnet.uiTest
> Bundle-Version: 1.0.0.qualifier
> Bundle-Vendor: MNET
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> Service-Component: OSGI-INF/component.xml
> Import-Package: org.eclipse.swt,
> org.eclipse.swt.widgets
> Export-Package: com.mnet.uiTest
>
>
> Component Definition for ui bundle:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="no links allowed" activate="startup"
> deactivate="shutdown" immediate="true" name="com.mnet.uiTest">
> <implementation class="com.mnet.uiTest.UITest"/>
> <service>
> <provide interface="com.mnet.uiTest.UITest"/>
> </service>
> </scr:component>
>
>
>
> GUI Class Code:
>
> package com.mnet.uiTest;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Text;
>
>
> public class UITest implements Runnable {
> private Display display;
> private boolean isRunning;
> private Text txtWindow;
>
> @Override
> public void run(){
> display = new Display();
>
> Shell myShell = new Shell(display);
> myShell.setSize(600, 600);
> txtWindow = new Text(myShell, SWT.MULTI | SWT.V_SCROLL);
> txtWindow.setText("Starting");
> txtWindow.setSize(200, 200);
> myShell.open();
> runDisplayEventQueue();
> }
>
> private void runDisplayEventQueue() {
> isRunning = true;
> while (isRunning && !display.isDisposed())
> try {
> if (!display.readAndDispatch())
> display.sleep();
> } catch (Throwable t) {
> t.printStackTrace();
> }
> isRunning = false;
> display.dispose();
> shutdown();
> }
>
> public void startup() {
> System.out.println("Starting GUI");
> new Thread
> (this).start(); }
>
> public void shutdown() {
> System.out.println("shutting down gui");
> if(isRunning)
> display.syncExec( new Runnable() { public void run() {
> display.dispose();} });
> }
>
> }
>
>
>
|
|
|
|
Re: SWT and Equinox product export problems [message #797742 is a reply to message #797734] |
Mon, 13 February 2012 21:23 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
.... and how do you start the application? The swt-fragments use filters
Eclipse-PlatformFilter (-os, -ws and -arch) which are passed in eclipse.
Tom
Am 13.02.12 22:12, schrieb Tom Schindl:
> In the export there's only the linux-swt fragment. On which OS are you
> running?
>
> Tom
>
> Am 13.02.12 22:03, schrieb Missing name Mising name:
>> So I'm making a plugin project that uses SWT for the gui and declarative
>> services for loading the gui service up.
>>
>> My application launches fine with the run configuration I use in
>> eclipse. The gui starts up and we all dance and sing. However,
>> whenever I make a product definition from this runtime config and export
>> it, the gui won't start and the OSGI console throws me
>> NoClassDefFoundError whenever it hits an import for anything in the SWT
>> libraries.
>>
>> I made a very simple project to demonstrate this behavior. All it does
>> is load up a window with some text in a control. Works fine when I run
>> from the eclipse environment, and then doesn't when I run it after I export
>>
>> What I've noticed is that when running from eclipse, the platform
>> specific swt bundle fragment shows as resolved. It also tells me that
>> the generic swt bundle has a fragment bundle associate with it.
>> However, the osgi console only shows that it's installed when run from
>> the executable.
>>
>> Run From Eclipse Environment:
>>
>> id State Bundle
>> 0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
>> 1 ACTIVE org.eclipse.osgi.services_3.2.0.v20090520-1800
>> 2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
>> 4 ACTIVE org.eclipse.swt_3.5.2.v3557f
>> Fragments=5
>> 5 RESOLVED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
>> Master=4
>> 6 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
>> 7 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
>> 8 ACTIVE com.mnet.uiTest_1.0.0.qualifier
>> 9 INSTALLED org.eclipse.swt.win32.win32.x86_3.5.2.v3557f
>> 10 INSTALLED org.eclipse.swt.win32.win32.x86_64_3.5.2.v3557f
>> 11 INSTALLED org.eclipse.swt.wpf.win32.x86_3.5.2.v3557f
>>
>>
>> Run From exported product:
>> id State Bundle
>> 0 ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
>> 1 ACTIVE com.mnet.uiTest_1.0.0.201202131522
>> 2 ACTIVE org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100
>> 3 ACTIVE org.eclipse.equinox.ds_1.1.1.R35x_v20090806
>> 4 ACTIVE org.eclipse.equinox.util_1.0.100.v20090520-1800
>> 5 RESOLVED org.eclipse.osgi.services_3.2.0.v20090520-1800
>> 6 ACTIVE org.eclipse.swt_3.5.2.v3557f
>> 7 INSTALLED org.eclipse.swt.gtk.linux.x86_64_3.5.2.v3557f
>>
>>
>> Here is my product definition:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <?pde version="3.5"?>
>>
>> <product application="org.eclipse.ui.ide.workbench" useFeatures="false"
>> includeLaunchers="true">
>>
>> <configIni use="default">
>> </configIni>
>>
>> <launcherArgs>
>> <programArgs>-os ${target.os} -ws ${target.ws} -arch ${target.arch}
>> -nl ${target.nl} -console</programArgs>
>> <vmArgs>-Declipse.ignoreApp=true -Dosgi.noShutdown=true
>> -Dequinox.ds.print=true</vmArgs>
>> <vmArgsMac>-XstartOnFirstThread
>> -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
>> </launcherArgs>
>>
>>
>> <launcher name="test">
>> <solaris/>
>> <win useIco="false">
>> <bmp/>
>> </win>
>> </launcher>
>>
>> <vm>
>> </vm>
>>
>> <plugins>
>> <plugin id="com.mnet.uiTest"/>
>> <plugin id="org.eclipse.equinox.common"/>
>> <plugin id="org.eclipse.equinox.ds"/>
>> <plugin id="org.eclipse.equinox.util"/>
>> <plugin id="org.eclipse.osgi"/>
>> <plugin id="org.eclipse.osgi.services"/>
>> <plugin id="org.eclipse.swt"/>
>> <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
>> <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
>> <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
>> <plugin id="org.eclipse.swt.wpf.win32.x86" fragment="true"/>
>> </plugins>
>>
>> <configurations>
>> <plugin id="com.mnet.uiTest" autoStart="true" startLevel="0" />
>> <plugin id="org.eclipse.equinox.common" autoStart="true"
>> startLevel="2" />
>> <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="0" />
>> <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" />
>> <plugin id="org.eclipse.swt" autoStart="true" startLevel="0" />
>> </configurations>
>>
>> </product>
>>
>>
>> Manifest for ui bundle:
>>
>> Manifest-Version: 1.0
>> Bundle-ManifestVersion: 2
>> Bundle-Name: UiTest
>> Bundle-SymbolicName: com.mnet.uiTest
>> Bundle-Version: 1.0.0.qualifier
>> Bundle-Vendor: MNET
>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>> Service-Component: OSGI-INF/component.xml
>> Import-Package: org.eclipse.swt,
>> org.eclipse.swt.widgets
>> Export-Package: com.mnet.uiTest
>>
>>
>> Component Definition for ui bundle:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <scr:component xmlns:scr="no links allowed" activate="startup"
>> deactivate="shutdown" immediate="true" name="com.mnet.uiTest">
>> <implementation class="com.mnet.uiTest.UITest"/>
>> <service>
>> <provide interface="com.mnet.uiTest.UITest"/>
>> </service>
>> </scr:component>
>>
>>
>>
>> GUI Class Code:
>>
>> package com.mnet.uiTest;
>>
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.widgets.Display;
>> import org.eclipse.swt.widgets.Shell;
>> import org.eclipse.swt.widgets.Text;
>>
>>
>> public class UITest implements Runnable {
>> private Display display;
>> private boolean isRunning;
>> private Text txtWindow;
>>
>> @Override
>> public void run(){
>> display = new Display();
>>
>> Shell myShell = new Shell(display);
>> myShell.setSize(600, 600);
>> txtWindow = new Text(myShell, SWT.MULTI | SWT.V_SCROLL);
>> txtWindow.setText("Starting");
>> txtWindow.setSize(200, 200);
>> myShell.open();
>> runDisplayEventQueue();
>> }
>>
>> private void runDisplayEventQueue() {
>> isRunning = true;
>> while (isRunning && !display.isDisposed())
>> try {
>> if (!display.readAndDispatch())
>> display.sleep();
>> } catch (Throwable t) {
>> t.printStackTrace();
>> }
>> isRunning = false;
>> display.dispose();
>> shutdown();
>> }
>>
>> public void startup() {
>> System.out.println("Starting GUI");
>> new Thread
>> (this).start(); }
>>
>> public void shutdown() {
>> System.out.println("shutting down gui");
>> if(isRunning)
>> display.syncExec( new Runnable() { public void run() {
>> display.dispose();} });
>> }
>>
>> }
>>
>>
>>
>
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04556 seconds