Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT fails to load x:Class class
XWT fails to load x:Class class [message #535287] Fri, 21 May 2010 21:30 Go to next message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
I created a small plugin project which has a simple Composite with two buttons. I created a SelectionEvent handler for one of the buttons. Without this handler the Composite appears to load fine, but as soon as I add the event handler in .xwt it fails to load. Turns out if fails to load the class containing the event handler which is specified in x:Class.

Is this a known limitation or a bug?


Here is the XWT file

<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:networkeditor.config.ui"
xmlns:j="clr-namespace:java.lang" x:Class="networkeditor.config.ui.MyConfigDialog"
x:DataContext="networkeditor.config.ui.MyConfigData">
<Composite.layout>
<GridLayout numColumns="2" />
</Composite.layout>
<Button x:style="SWT.PUSH" text="Push Me" SelectionEvent="performSelectionEvent"></Button>
<Button x:style="SWT.PUSH" text="Don't push me"></Button>
</Composite>

Here is the Java class.

package networkeditor.config.ui;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;

public class MyConfigDialog extends Composite {

public MyConfigDialog(Composite parent, int style) {
super(parent, style);
// TODO Auto-generated constructor stub
}

protected void performSelectionEvent (Event event) {
MessageDialog.openInformation(getShell(), "Title", "you pushed me");
}

}

And here is the data context class.

package networkeditor.config.ui;

public class MyConfigData {

}

Here is how I invoke it.

public static void main (String [] args) {
try {
URL file = MyConfigData.class.getResource("/networkeditor/config/ui/MyConfigDialog.xwt ");
XWT.open(file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


BTW, When I press the Preview button in the XWT file editor (in XWT perspective) the event handler is invoked correctly. So there is something that I am not doing correctly.

I tried passing parent composite so that ILoadingContext is set differently.
I exported the package containing these classes via MANIFEST.MF.
I changed Eclipse-BuddyPolicy: global (although it shouldn't help in theory)
I checked the Eclipse-BuddyPolicy in org.eclipse.e4.xwt and it is not set so I don't know how the xwt plugin loads these classes. I am using ver 0.9.1 from 2010 04 06.

XWT simply can't load the MyConfigDialog class.

Any help will be appreciated.


Thanks,

Swavek



[Updated on: Tue, 25 May 2010 19:34]

Report message to a moderator

Re: XWT fails to load x:Class class [message #535820 is a reply to message #535287] Tue, 25 May 2010 19:42 Go to previous messageGo to next message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
After looking into how the new XWT designer performs class loading, I tried to load to specify the classloader that XWT should be using. Now it works when I run within Eclipse. I used an alternative load method which takes the parent component, input stream and url to load.

Composite configPanelsContainer = new Composite(container, SWT.NONE);
StackLayout stackLayout = new StackLayout();
configPanelsContainer.setLayout(stackLayout);
String configURLString = "/networkeditor/config/ui/MyConfigDialog.xwt";
URL configPanelURL = getClass().getClassLoader().getResource(configURLString);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(configURLStr ing);

// load it
configPanel = XWT.load(configPanelsContainer, inputStream, configPanelURL, getDataContext());

However when I try to run my app after exporting from Eclipse environment the loading of the xwt file doesn't work . I get this exception:

!ENTRY com.infogix.dptoolcatalog 4 1 2010-05-25 14:31:36.552
!MESSAGE my error
!STACK 0
java.io.FileNotFoundException: /networkeditor/config/ui\MyConfigDialog.xwt
at org.eclipse.osgi.framework.internal.protocol.bundleresource. Handler.findBundleEntry(Handler.java:51)
at org.eclipse.osgi.framework.internal.core.BundleResourceHandl er.openConnection(BundleResourceHandler.java:175)
at java.net.URL.openConnection(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.eclipse.e4.xwt.internal.xml.DocumentRoot.openStream(Docu mentRoot.java:137)
at org.eclipse.e4.xwt.internal.xml.ElementManager.load(ElementM anager.java:252)
at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:643)
at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java: 863)
at org.eclipse.e4.xwt.XWTLoader.load(XWTLoader.java:729)
at org.eclipse.e4.xwt.XWT.load(XWT.java:425)
at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial og.getConfigPanelsMap(NodePropertiesDialog.java:289)
at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial og.createDialogArea(NodePropertiesDialog.java:218)
at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 760)
....

[Updated on: Tue, 25 May 2010 19:44]

Report message to a moderator

Re: XWT fails to load x:Class class [message #535848 is a reply to message #535820] Wed, 26 May 2010 01:21 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
This bug is fixed in the last build: e4 1.0 M6

Best regards
Yves YANG
"Swavek" <slorenc@infogix.com> wrote in message
news:hth96a$ukj$1@build.eclipse.org...
> After looking into how the new XWT designer performs class loading, I
> tried to load to specify the classloader that XWT should be using. Now it
> works when I run within Eclipse. I used an alternative load method which
> takes the parent component, input stream and url to load.
>
> Composite configPanelsContainer = new Composite(container, SWT.NONE);
> StackLayout stackLayout = new StackLayout();
> configPanelsContainer.setLayout(stackLayout);
>
> URL configPanelURL =
> getClass().getClassLoader().getResource(configURLString);
> InputStream inputStream =
> getClass().getClassLoader().getResourceAsStream(configURLStr ing);
>
> // load it configPanel = XWT.load(configPanelsContainer, inputStream,
> configPanelURL, getDataContext());
>
> However when I try to run my app after exporting from Eclipse environment
> the loading of the xwt file doesn't work . I get this exception:
>
> !ENTRY com.infogix.dptoolcatalog 4 1 2010-05-25 14:31:36.552
> !MESSAGE my error
> !STACK 0
> java.io.FileNotFoundException: /my/config\MyConfigPanel.xwt
> at org.eclipse.osgi.framework.internal.protocol.bundleresource.
> Handler.findBundleEntry(Handler.java:51)
> at org.eclipse.osgi.framework.internal.core.BundleResourceHandl
> er.openConnection(BundleResourceHandler.java:175)
> at java.net.URL.openConnection(Unknown Source)
> at java.net.URL.openStream(Unknown Source)
> at org.eclipse.e4.xwt.internal.xml.DocumentRoot.openStream(Docu
> mentRoot.java:137)
> at org.eclipse.e4.xwt.internal.xml.ElementManager.load(ElementM
> anager.java:252)
> at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:643)
> at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java: 863)
> at org.eclipse.e4.xwt.XWTLoader.load(XWTLoader.java:729)
> at org.eclipse.e4.xwt.XWT.load(XWT.java:425)
> at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial
> og.getConfigPanelsMap(NodePropertiesDialog.java:289)
> at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial
> og.createDialogArea(NodePropertiesDialog.java:218)
> at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 760)
> ...
Re: XWT fails to load x:Class class [message #536069 is a reply to message #535848] Wed, 26 May 2010 20:49 Go to previous messageGo to next message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
Yves,

I just downloaded the latest e4 M6 and verified that this problem goes away. Thank you. I was almost ready to give up on XWT.

Is setting of class loader still necessary for the XWT.load to succeed in loading x:Class? None of the examples are showing that this is necessary but I had to add a code like this to get the event handler class loaded. This class and the .xwt file are in the same package in the same plugin, but XWT has trouble loading it.

// override the class loader for the x:Class classes located within this plugin or else they will not be loaded
DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
loadingContext.setClassLoader(getClass().getClassLoader());
XWTLoaderManager.getActive().setLoadingContext(loadingContex t);

.. then call XWT.load

Thanks,
Swavek
Re: XWT fails to load x:Class class [message #536896 is a reply to message #536069] Mon, 31 May 2010 12:45 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
> Is setting of class loader still necessary for the XWT.load to succeed in
> loading x:Class? None of the examples are showing that this is necessary
> but I had to add a code like this to get the event handler class loaded.
> This class and the .xwt file are in the same package in the same plugin,
> but XWT has trouble loading it.

If your application is in plugin, the setting of class loader is always
necessary. It is not a problem of the implementation of XWT. It is a common
issue of OSGi.

Best regards
Yves YANG
"Swavek" <slorenc@infogix.com> wrote in message
news:htk1g7$aau$1@build.eclipse.org...
> Yves,
>
> I just downloaded the latest e4 M6 and verified that this problem goes
> away. Thank you. I was almost ready to give up on XWT.
>
> Is setting of class loader still necessary for the XWT.load to succeed in
> loading x:Class? None of the examples are showing that this is necessary
> but I had to add a code like this to get the event handler class loaded.
> This class and the .xwt file are in the same package in the same plugin,
> but XWT has trouble loading it.
>
> // override the class loader for the x:Class classes located within this
> plugin or else they will not be loaded
> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
> loadingContext.setClassLoader(getClass().getClassLoader());
> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>
> . then call XWT.load
>
> Thanks,
> Swavek
>
Re: XWT fails to load x:Class class [message #536906 is a reply to message #536896] Mon, 31 May 2010 13:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Yves,

I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)

Out of curiosity would it be possible instead of setting the class
loader to provide an OSGified load-Method.

XWT.load(Bundle bundle,String resource) this could make all relative
resources (Images, Classes, ...) relative to this bundle?

Tom

Am 31.05.10 14:45, schrieb Yves YANG:
>> Is setting of class loader still necessary for the XWT.load to succeed in
>> loading x:Class? None of the examples are showing that this is necessary
>> but I had to add a code like this to get the event handler class loaded.
>> This class and the .xwt file are in the same package in the same plugin,
>> but XWT has trouble loading it.
>
> If your application is in plugin, the setting of class loader is always
> necessary. It is not a problem of the implementation of XWT. It is a common
> issue of OSGi.
>
> Best regards
> Yves YANG
> "Swavek" <slorenc@infogix.com> wrote in message
> news:htk1g7$aau$1@build.eclipse.org...
>> Yves,
>>
>> I just downloaded the latest e4 M6 and verified that this problem goes
>> away. Thank you. I was almost ready to give up on XWT.
>>
>> Is setting of class loader still necessary for the XWT.load to succeed in
>> loading x:Class? None of the examples are showing that this is necessary
>> but I had to add a code like this to get the event handler class loaded.
>> This class and the .xwt file are in the same package in the same plugin,
>> but XWT has trouble loading it.
>>
>> // override the class loader for the x:Class classes located within this
>> plugin or else they will not be loaded
>> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
>> loadingContext.setClassLoader(getClass().getClassLoader());
>> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>>
>> . then call XWT.load
>>
>> Thanks,
>> Swavek
>>
>
>
Re: XWT fails to load x:Class class [message #537017 is a reply to message #536906] Mon, 31 May 2010 23:28 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
Hi Tom,
> I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)
You are absolutely right. Thanks for correcting me.

> Out of curiosity would it be possible instead of setting the class
> loader to provide an OSGified load-Method.
>
> XWT.load(Bundle bundle,String resource) this could make all relative
> resources (Images, Classes, ...) relative to this bundle?
I think it should have the same result. The class loader can load resources
as well. We do use the classloader to load images, XWT files.

yves
"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:hu0c3a$53n$1@build.eclipse.org...
> Hi Yves,
>
> I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)
>
> Out of curiosity would it be possible instead of setting the class
> loader to provide an OSGified load-Method.
>
> XWT.load(Bundle bundle,String resource) this could make all relative
> resources (Images, Classes, ...) relative to this bundle?
>
> Tom
>
> Am 31.05.10 14:45, schrieb Yves YANG:
>>> Is setting of class loader still necessary for the XWT.load to succeed
>>> in
>>> loading x:Class? None of the examples are showing that this is
>>> necessary
>>> but I had to add a code like this to get the event handler class loaded.
>>> This class and the .xwt file are in the same package in the same plugin,
>>> but XWT has trouble loading it.
>>
>> If your application is in plugin, the setting of class loader is always
>> necessary. It is not a problem of the implementation of XWT. It is a
>> common
>> issue of OSGi.
>>
>> Best regards
>> Yves YANG
>> "Swavek" <slorenc@infogix.com> wrote in message
>> news:htk1g7$aau$1@build.eclipse.org...
>>> Yves,
>>>
>>> I just downloaded the latest e4 M6 and verified that this problem goes
>>> away. Thank you. I was almost ready to give up on XWT.
>>>
>>> Is setting of class loader still necessary for the XWT.load to succeed
>>> in
>>> loading x:Class? None of the examples are showing that this is
>>> necessary
>>> but I had to add a code like this to get the event handler class loaded.
>>> This class and the .xwt file are in the same package in the same plugin,
>>> but XWT has trouble loading it.
>>>
>>> // override the class loader for the x:Class classes located within this
>>> plugin or else they will not be loaded
>>> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
>>> loadingContext.setClassLoader(getClass().getClassLoader());
>>> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>>>
>>> . then call XWT.load
>>>
>>> Thanks,
>>> Swavek
>>>
>>
>>
>
Re: XWT fails to load x:Class class [message #576806 is a reply to message #535848] Wed, 26 May 2010 20:49 Go to previous message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
Yves,

I just downloaded the latest e4 M6 and verified that this problem goes away. Thank you. I was almost ready to give up on XWT.

Is setting of class loader still necessary for the XWT.load to succeed in loading x:Class? None of the examples are showing that this is necessary but I had to add a code like this to get the event handler class loaded. This class and the .xwt file are in the same package in the same plugin, but XWT has trouble loading it.

// override the class loader for the x:Class classes located within this plugin or else they will not be loaded
DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
loadingContext.setClassLoader(getClass().getClassLoader());
XWTLoaderManager.getActive().setLoadingContext(loadingContex t);

.. then call XWT.load

Thanks,
Swavek
Re: XWT fails to load x:Class class [message #576834 is a reply to message #536069] Mon, 31 May 2010 12:45 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
> Is setting of class loader still necessary for the XWT.load to succeed in
> loading x:Class? None of the examples are showing that this is necessary
> but I had to add a code like this to get the event handler class loaded.
> This class and the .xwt file are in the same package in the same plugin,
> but XWT has trouble loading it.

If your application is in plugin, the setting of class loader is always
necessary. It is not a problem of the implementation of XWT. It is a common
issue of OSGi.

Best regards
Yves YANG
"Swavek" <slorenc@infogix.com> wrote in message
news:htk1g7$aau$1@build.eclipse.org...
> Yves,
>
> I just downloaded the latest e4 M6 and verified that this problem goes
> away. Thank you. I was almost ready to give up on XWT.
>
> Is setting of class loader still necessary for the XWT.load to succeed in
> loading x:Class? None of the examples are showing that this is necessary
> but I had to add a code like this to get the event handler class loaded.
> This class and the .xwt file are in the same package in the same plugin,
> but XWT has trouble loading it.
>
> // override the class loader for the x:Class classes located within this
> plugin or else they will not be loaded
> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
> loadingContext.setClassLoader(getClass().getClassLoader());
> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>
> . then call XWT.load
>
> Thanks,
> Swavek
>
Re: XWT fails to load x:Class class [message #576845 is a reply to message #536896] Mon, 31 May 2010 13:03 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Yves,

I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)

Out of curiosity would it be possible instead of setting the class
loader to provide an OSGified load-Method.

XWT.load(Bundle bundle,String resource) this could make all relative
resources (Images, Classes, ...) relative to this bundle?

Tom

Am 31.05.10 14:45, schrieb Yves YANG:
>> Is setting of class loader still necessary for the XWT.load to succeed in
>> loading x:Class? None of the examples are showing that this is necessary
>> but I had to add a code like this to get the event handler class loaded.
>> This class and the .xwt file are in the same package in the same plugin,
>> but XWT has trouble loading it.
>
> If your application is in plugin, the setting of class loader is always
> necessary. It is not a problem of the implementation of XWT. It is a common
> issue of OSGi.
>
> Best regards
> Yves YANG
> "Swavek" <slorenc@infogix.com> wrote in message
> news:htk1g7$aau$1@build.eclipse.org...
>> Yves,
>>
>> I just downloaded the latest e4 M6 and verified that this problem goes
>> away. Thank you. I was almost ready to give up on XWT.
>>
>> Is setting of class loader still necessary for the XWT.load to succeed in
>> loading x:Class? None of the examples are showing that this is necessary
>> but I had to add a code like this to get the event handler class loaded.
>> This class and the .xwt file are in the same package in the same plugin,
>> but XWT has trouble loading it.
>>
>> // override the class loader for the x:Class classes located within this
>> plugin or else they will not be loaded
>> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
>> loadingContext.setClassLoader(getClass().getClassLoader());
>> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>>
>> . then call XWT.load
>>
>> Thanks,
>> Swavek
>>
>
>
Re: XWT fails to load x:Class class [message #576874 is a reply to message #536906] Mon, 31 May 2010 23:28 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
Hi Tom,
> I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)
You are absolutely right. Thanks for correcting me.

> Out of curiosity would it be possible instead of setting the class
> loader to provide an OSGified load-Method.
>
> XWT.load(Bundle bundle,String resource) this could make all relative
> resources (Images, Classes, ...) relative to this bundle?
I think it should have the same result. The class loader can load resources
as well. We do use the classloader to load images, XWT files.

yves
"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:hu0c3a$53n$1@build.eclipse.org...
> Hi Yves,
>
> I wouldn't call it an OSGi-Issue but an OSGi-Requirement :-)
>
> Out of curiosity would it be possible instead of setting the class
> loader to provide an OSGified load-Method.
>
> XWT.load(Bundle bundle,String resource) this could make all relative
> resources (Images, Classes, ...) relative to this bundle?
>
> Tom
>
> Am 31.05.10 14:45, schrieb Yves YANG:
>>> Is setting of class loader still necessary for the XWT.load to succeed
>>> in
>>> loading x:Class? None of the examples are showing that this is
>>> necessary
>>> but I had to add a code like this to get the event handler class loaded.
>>> This class and the .xwt file are in the same package in the same plugin,
>>> but XWT has trouble loading it.
>>
>> If your application is in plugin, the setting of class loader is always
>> necessary. It is not a problem of the implementation of XWT. It is a
>> common
>> issue of OSGi.
>>
>> Best regards
>> Yves YANG
>> "Swavek" <slorenc@infogix.com> wrote in message
>> news:htk1g7$aau$1@build.eclipse.org...
>>> Yves,
>>>
>>> I just downloaded the latest e4 M6 and verified that this problem goes
>>> away. Thank you. I was almost ready to give up on XWT.
>>>
>>> Is setting of class loader still necessary for the XWT.load to succeed
>>> in
>>> loading x:Class? None of the examples are showing that this is
>>> necessary
>>> but I had to add a code like this to get the event handler class loaded.
>>> This class and the .xwt file are in the same package in the same plugin,
>>> but XWT has trouble loading it.
>>>
>>> // override the class loader for the x:Class classes located within this
>>> plugin or else they will not be loaded
>>> DefaultLoadingContext loadingContext = new DefaultLoadingContext ();
>>> loadingContext.setClassLoader(getClass().getClassLoader());
>>> XWTLoaderManager.getActive().setLoadingContext(loadingContex t);
>>>
>>> . then call XWT.load
>>>
>>> Thanks,
>>> Swavek
>>>
>>
>>
>
Previous Topic:Share data between XWT instances ?
Next Topic:Opening the e4 workbench designer distorts the screen
Goto Forum:
  


Current Time: Thu Apr 18 12:47:39 GMT 2024

Powered by FUDForum. Page generated in 0.02468 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top