Using ILocaleChangeService [message #1600556] |
Wed, 04 February 2015 05:15  |
Eclipse User |
|
|
|
Hello,
When using the ILocaleChangeService normally in my application (e.g., in a handler), it works fine.
However, when I try to get it injected in a Controller (with the usual FXMLLoader), I get the following error :
Quote:
javafx.fxml.LoadException:
/be/groups/portfolio/desktop/login/LoginScreen.fxml:13
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2419)
at org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:440)
at org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:246)
at org.eclipse.fx.ui.di.InjectingFXMLLoader$1.loadWithController(InjectingFXMLLoader.java:91)
at be.groups.portfolio.desktop.login.LoginManager.getLoginNode(LoginManager.java:63)
at be.groups.portfolio.desktop.login.LoginManager.initStage(LoginManager.java:51)
at be.groups.portfolio.desktop.login.LoginManager.showLogin(LoginManager.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:225)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:107)
at org.eclipse.fx.ui.workbench.base.AbstractE4Application$2.call(AbstractE4Application.java:311)
at org.eclipse.fx.ui.workbench.fx.internal.UISynchronizeImpl.syncExec(UISynchronizeImpl.java:52)
at org.eclipse.fx.ui.workbench.base.AbstractE4Application.invokePostContextCreate(AbstractE4Application.java:308)
at org.eclipse.fx.ui.workbench.base.AbstractE4Application.createE4Workbench(AbstractE4Application.java:229)
at org.eclipse.fx.ui.workbench.fx.E4Application.initE4Workbench(E4Application.java:259)
at org.eclipse.fx.ui.workbench.fx.E4Application$1.run(E4Application.java:134)
at org.eclipse.fx.ui.workbench.fx.E4Application.jfxStart(E4Application.java:169)
at org.eclipse.fx.ui.workbench.fx.DefaultJFXApp.start(DefaultJFXApp.java:57)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$56/399334924.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$52/772047381.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$54/743972953.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$53/1727532637.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$44/1069963390.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in org.eclipse.fx.ui.workbench.base.internal.FixedLocaleChangeService
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:346)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.fx.ui.workbench.base.internal.FixedLocaleChangeServiceCF.compute(FixedLocaleChangeServiceCF.java:23)
at org.eclipse.e4.core.contexts.ContextFunction.compute(ContextFunction.java:44)
at org.eclipse.e4.core.internal.contexts.ValueComputation.get(ValueComputation.java:61)
at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:246)
at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:257)
at org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:213)
at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:68)
at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:107)
at org.eclipse.e4.core.internal.contexts.EclipseContext.runAndTrack(EclipseContext.java:319)
at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier.get(ContextObjectSupplier.java:167)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveArgs(InjectorImpl.java:469)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:397)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:109)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.fx.ui.di.InjectingFXMLLoader$ControllerFactory.call(InjectingFXMLLoader.java:299)
at org.eclipse.fx.ui.di.InjectingFXMLLoader$ControllerFactory.call(InjectingFXMLLoader.java:1)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:925)
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:2701)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521)
... 37 more
Exception in Application start method
The invoking code is :
private Parent getLoginNode()
{
FXMLBuilder<GridPane> builder = FxmlFactory.loadRequestorRelative("LoginScreen.fxml") ;
FXMLBuilder.Data<GridPane, LoginScreenController> nodeControllerPair ;
try
{
nodeControllerPair = builder.loadWithController() ;
nodeControllerPair.getController().setCondition(condition);
return nodeControllerPair.getNode() ;
}
catch (Exception e)
{
e.printStackTrace();
return null ;
}
}
And in the Controller, the normal "@Inject private ILocaleChangeService lcs". I also have a MessageRegistry ("@Inject private LoginMessagesRegistry registry"), which gets injected just fine.
Perhaps worth to mention : the aforementioned code is called in a method annotated with @PostContextCreate.
Am I doing something wrong or should I file a bug ... ?
Thomas Elskens
|
|
|
Re: Using ILocaleChangeService [message #1600578 is a reply to message #1600556] |
Wed, 04 February 2015 05:35   |
Eclipse User |
|
|
|
Hi,
Is this in a lifecycle hook? ILocalChangeService is not yet available at
this point, it requires at least to have the application model loaded.
I guess you are doing this to flip the language, when the user logs in?
If my assumption is correct then you have to do this directly on the
context at this point in time using
context.set(TranslationService.LOCALE, ....)
Please note there's a change coming to this with Mars:
* Luna the type set was a String
* Mars the type set is a Locale
I've just adjusted our code base to this internal change
https://bugs.eclipse.org/bugs/show_bug.cgi?id=459108
Tom
On 04.02.15 11:15, Thomas Elskens wrote:
> Hello,
>
> When using the ILocaleChangeService normally in my application (e.g., in
> a handler), it works fine.
> However, when I try to get it injected in a Controller (with the usual
> FXMLLoader), I get the following error :
>
> Quote:
>> javafx.fxml.LoadException:
>> /be/groups/portfolio/desktop/login/LoginScreen.fxml:13
>>
>> at
>> javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595)
>> at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
>> at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2419)
>> at
>> org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:440)
>>
>> at
>> org.eclipse.fx.osgi.util.OSGiFXMLLoader.loadWithController(OSGiFXMLLoader.java:246)
>>
>> at
>> org.eclipse.fx.ui.di.InjectingFXMLLoader$1.loadWithController(InjectingFXMLLoader.java:91)
>>
>> at
>> be.groups.portfolio.desktop.login.LoginManager.getLoginNode(LoginManager.java:63)
>>
>> at
>> be.groups.portfolio.desktop.login.LoginManager.initStage(LoginManager.java:51)
>>
>> at
>> be.groups.portfolio.desktop.login.LoginManager.showLogin(LoginManager.java:35)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>> at
>> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:225)
>>
>> at
>> org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:107)
>>
>> at
>> org.eclipse.fx.ui.workbench.base.AbstractE4Application$2.call(AbstractE4Application.java:311)
>>
>> at
>> org.eclipse.fx.ui.workbench.fx.internal.UISynchronizeImpl.syncExec(UISynchronizeImpl.java:52)
>>
>> at
>> org.eclipse.fx.ui.workbench.base.AbstractE4Application.invokePostContextCreate(AbstractE4Application.java:308)
>>
>> at
>> org.eclipse.fx.ui.workbench.base.AbstractE4Application.createE4Workbench(AbstractE4Application.java:229)
>>
>> at
>> org.eclipse.fx.ui.workbench.fx.E4Application.initE4Workbench(E4Application.java:259)
>>
>> at
>> org.eclipse.fx.ui.workbench.fx.E4Application$1.run(E4Application.java:134)
>>
>> at
>> org.eclipse.fx.ui.workbench.fx.E4Application.jfxStart(E4Application.java:169)
>>
>> at
>> org.eclipse.fx.ui.workbench.fx.DefaultJFXApp.start(DefaultJFXApp.java:57)
>> at
>> com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
>>
>> at
>> com.sun.javafx.application.LauncherImpl$$Lambda$56/399334924.run(Unknown
>> Source)
>> at
>> com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
>>
>> at
>> com.sun.javafx.application.PlatformImpl$$Lambda$52/772047381.run(Unknown
>> Source)
>> at
>> com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
>>
>> at
>> com.sun.javafx.application.PlatformImpl$$Lambda$54/743972953.run(Unknown
>> Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
>>
>> at
>> com.sun.javafx.application.PlatformImpl$$Lambda$53/1727532637.run(Unknown
>> Source)
>> at
>> com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
>>
>> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
>> at
>> com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
>>
>> at
>> com.sun.glass.ui.win.WinApplication$$Lambda$44/1069963390.run(Unknown
>> Source)
>> at java.lang.Thread.run(Thread.java:745)
>> Caused by: org.eclipse.e4.core.di.InjectionException: Could not find
>> satisfiable constructor in
>> org.eclipse.fx.ui.workbench.base.internal.FixedLocaleChangeService
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:346)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
>> at
>> org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
>>
>> at
>> org.eclipse.fx.ui.workbench.base.internal.FixedLocaleChangeServiceCF.compute(FixedLocaleChangeServiceCF.java:23)
>>
>> at
>> org.eclipse.e4.core.contexts.ContextFunction.compute(ContextFunction.java:44)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.ValueComputation.get(ValueComputation.java:61)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:246)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:257)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:213)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:68)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:107)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.runAndTrack(EclipseContext.java:319)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.ContextObjectSupplier.get(ContextObjectSupplier.java:167)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.resolveArgs(InjectorImpl.java:469)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:397)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:109)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
>> at
>> org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
>>
>> at
>> org.eclipse.fx.ui.di.InjectingFXMLLoader$ControllerFactory.call(InjectingFXMLLoader.java:299)
>>
>> at
>> org.eclipse.fx.ui.di.InjectingFXMLLoader$ControllerFactory.call(InjectingFXMLLoader.java:1)
>>
>> at
>> javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:925)
>> 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:2701)
>> at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521)
>> ... 37 more
>> Exception in Application start method
>
>
> The invoking code is :
>
>
> private Parent getLoginNode()
> {
> FXMLBuilder<GridPane> builder =
> FxmlFactory.loadRequestorRelative("LoginScreen.fxml") ;
> FXMLBuilder.Data<GridPane, LoginScreenController>
> nodeControllerPair ;
> try
> {
> nodeControllerPair = builder.loadWithController() ;
> nodeControllerPair.getController().setCondition(condition);
> return nodeControllerPair.getNode() ;
> }
> catch (Exception e)
> {
> e.printStackTrace();
> return null ;
> }
> }
>
>
> And in the Controller, the normal "@Inject private ILocaleChangeService
> lcs". I also have a MessageRegistry ("@Inject private
> LoginMessagesRegistry registry"), which gets injected just fine.
> Perhaps worth to mention : the aforementioned code is called in a method
> annotated with @PostContextCreate.
> Am I doing something wrong or should I file a bug ... ?
>
> Thomas Elskens
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09926 seconds