Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Using FXMLLoaderFactory to load an FXML with a controller in a different bundle
Using FXMLLoaderFactory to load an FXML with a controller in a different bundle [message #1706846] Mon, 31 August 2015 13:06 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi,

I am writing a utility that uses FXMLLoaderFactory to load an FXML and use dependency injection with the controller. (The reason behind this is that the FXML is loaded from a server and is not located inside the bundle.)

The issue that I am facing is:

javafx.fxml.LoadException: 
	at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
	at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
	at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:918)
	at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
	at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
	at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
	at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2429)
	at org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:440)
	...
Caused by: java.lang.ClassNotFoundException: de.emsw.gosa.product.ega.controller.DokumenteController cannot be found by de.emsw.gosa.fx.util_1.0.0.qualifier
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:916)
	... 132 more


The reason is that the controller class is not in the same bundle with the utility class. Is it possible to set the class loader for FXMLLoaderFactory, so that it searches in a bundle that I can specify?

Thanks!
Christoph
Re: Using FXMLLoaderFactory to load an FXML with a controller in a different bundle [message #1706947 is a reply to message #1706846] Tue, 01 September 2015 07:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
So I guess you better use InjectingFXMLLoader, not? FXMLLoaderFactory in
simply wrapping that one. Disadvantage you get a direct dependency on
IEclipseContext.

Tom

On 31.08.15 15:06, Christoph Keimel wrote:
> Hi,
>
> I am writing a utility that uses FXMLLoaderFactory to load an FXML and
> use dependency injection with the controller. (The reason behind this
> is that the FXML is loaded from a server and is not located inside the
> bundle.)
>
> The issue that I am facing is:
>
> javafx.fxml.LoadException: at
> javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
> at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
> at
> javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:918)
> at
> javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
>
> at
> javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
> at
> javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
>
> at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
> at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
> at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2429)
> at
> org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:440)
>
> ...
> Caused by: java.lang.ClassNotFoundException:
> de.emsw.gosa.product.ega.controller.DokumenteController cannot be found
> by de.emsw.gosa.fx.util_1.0.0.qualifier
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
>
> at
> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at
> javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:916)
> ... 132 more
>
>
> The reason is that the controller class is not in the same bundle with
> the utility class. Is it possible to set the class loader for
> FXMLLoaderFactory, so that it searches in a bundle that I can specify?
>
> Thanks!
> Christoph
Re: Using FXMLLoaderFactory to load an FXML with a controller in a different bundle [message #1706965 is a reply to message #1706947] Tue, 01 September 2015 08:15 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Yeah, you are right. That gives me exactly what I need. Thanks!
Previous Topic:Please review new wiki page for errors
Next Topic:PerspectiveStack not visible
Goto Forum:
  


Current Time: Fri Apr 26 19:00:11 GMT 2024

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

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

Back to the top