Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Using contextvalue leads me to curious IllegalStateException
Using contextvalue leads me to curious IllegalStateException [message #1697880] Tue, 09 June 2015 10:24 Go to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
During applicaton startup, I use a ContextBoundValue<String> to keep track of the progress made of the user who tries to log into the application.

This value gets published (very normally) in the fxml controller of the loginscreen, like this :

@Inject
@ContextValue(LoginManager.LOGIN_STATUS_CONTEXT_KEY)
private ContextBoundValue<String> loginStatus ;
[...]
loginStatus.publish(LoginManager.LOGIN_STATUS_OK);


And I have the proof this publishing works correctly :

Quote:

DEBUG: 2015-06-09 11:57:43 [JavaFX Application Thread] LifecycleManager - Login status : loginStatusOk


But why then do I also get this stack trace ? Most noticebly, it says "java.lang.IllegalArgumentException: Variable be.groups.portfolio.loginstatus is not modifiable in the context WorkbenchContext", as stated below :
Quote:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1770)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1653)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
[...]
Caused by: java.lang.IllegalArgumentException: Variable be.groups.portfolio.loginstatus is not modifiable in the context WorkbenchContext
at org.eclipse.e4.core.internal.contexts.EclipseContext.internalModify(EclipseContext.java:385)
at org.eclipse.e4.core.internal.contexts.EclipseContext.modify(EclipseContext.java:375)
at org.eclipse.fx.core.di.context.internal.EclipseContextBoundValue.publish(EclipseContextBoundValue.java:119)
at login.LoginScreenController.setLoginStatus(LoginScreenController.java:128)
at login.LoginScreenController.handleConfirm(LoginScreenController.java:91)
... 95 more


I do not understand what it means, nor what it implies...

The lifecylemanager gets injected with a @Singleton @Creatable LoginManager,
this loginManager loads the loginscreen,
the controller of the loginscreen publishes the value,
and finally, the lifecyclemanager reads the value when the loginscreen is closed.

Shouldn't I assume those three classes are accessing the same context ?

Anybody a clue ?

Thanks for any advice,

Thomas Elskens
Re: Using contextvalue leads me to curious IllegalStateException [message #1697882 is a reply to message #1697880] Tue, 09 June 2015 10:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

It does not matter on which context the important thing is that you need
to tell the system in which context the value is tracked.

To do this you need to call on the IEclipseContext you want the value to
reside
IEclipseContext#declareModifiable(LoginManager.LOGIN_STATUS_CONTEXT_KEY).

In your case this is most likely the Root-Context.

Tom


On 09.06.15 12:24, Thomas Elskens wrote:
> During applicaton startup, I use a ContextBoundValue<String> to keep
> track of the progress made of the user who tries to log into the
> application.
> This value gets published (very normally) in the fxml controller of the
> loginscreen, like this :
>
>
> @Inject
> @ContextValue(LoginManager.LOGIN_STATUS_CONTEXT_KEY)
> private ContextBoundValue<String> loginStatus ;
> [...]
> loginStatus.publish(LoginManager.LOGIN_STATUS_OK);
>
>
> And I have the proof this publishing works correctly :
>
> Quote:
>> DEBUG: 2015-06-09 11:57:43 [JavaFX Application Thread]
>> LifecycleManager - Login status : loginStatusOk
>
>
> But why then do I also get this stack trace ? Most noticebly, it says
> "java.lang.IllegalArgumentException: Variable
> be.groups.portfolio.loginstatus is not modifiable in the context
> WorkbenchContext", as stated below :
> Quote:
>> Exception in thread "JavaFX Application Thread"
>> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>> at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1770)
>> at
>> javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1653)
>>
>> at
>> com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
>>
>> at
>> com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> [...]
>> Caused by: java.lang.IllegalArgumentException: Variable
>> be.groups.portfolio.loginstatus is not modifiable in the context
>> WorkbenchContext
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.internalModify(EclipseContext.java:385)
>>
>> at
>> org.eclipse.e4.core.internal.contexts.EclipseContext.modify(EclipseContext.java:375)
>>
>> at
>> org.eclipse.fx.core.di.context.internal.EclipseContextBoundValue.publish(EclipseContextBoundValue.java:119)
>>
>> at
>> login.LoginScreenController.setLoginStatus(LoginScreenController.java:128)
>>
>> at
>> login.LoginScreenController.handleConfirm(LoginScreenController.java:91)
>> ... 95 more
>
>
> I do not understand what it means, nor what it implies...
> The lifecylemanager gets injected with a @Singleton @Creatable
> LoginManager,
> this loginManager loads the loginscreen,
> the controller of the loginscreen publishes the value,
> and finally, the lifecyclemanager reads the value when the loginscreen
> is closed.
> Shouldn't I assume those three classes are accessing the same context ?
> Anybody a clue ?
>
> Thanks for any advice,
>
> Thomas Elskens
Re: Using contextvalue leads me to curious IllegalStateException [message #1697895 is a reply to message #1697882] Tue, 09 June 2015 12:15 Go to previous message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Okay this works, thanks a lot !
Previous Topic:The import javafx cannot be resolved
Next Topic:Detaching views using DnD
Goto Forum:
  


Current Time: Thu Sep 26 05:33:08 GMT 2024

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

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

Back to the top