Vaadin14 LanguageSelect


I jumpstarted a vaadin14 project from basic-starter-spring-gradle (exact version: 14.2.0 and I use the same for vaadin-bom). I followed the instructions and code samples from I setup the language images and implemented I18nProvider with all resource bundle files expected. The first time around, the page displays properly with the language select showing the correct images with the language names. However, the moment I select a language, nothing happens on the screen. I see a nul pointer stacktrace in the server logs (pasted below). After this event, all screens redirect to DefaultErrorHandler with obscure stacktrace (also caused by null pointer starting from BootStrap).

 ERROR com.vaadin.flow.server.DefaultErrorHandler - 
        at com.vaadin.flow.component.UI.setLocale(
        at com.vaadin.flow.server.VaadinSession.lambda$setLocale$0(
        at java.base/java.util.HashMap$Values.forEach(
        at java.base/java.util.Collections$UnmodifiableCollection.forEach(
        at com.vaadin.flow.server.VaadinSession.setLocale(
        at ch.carnet.kasparscherrer.LanguageSelect.lambda$new$868b9db0$1(
        at com.vaadin.flow.component.internal.AbstractFieldSupport.lambda$addValueChangeListener$828eca10$1(
        at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(
        at com.vaadin.flow.component.ComponentEventBus.fireEvent(
        at com.vaadin.flow.component.Component.fireEvent(
        at com.vaadin.flow.component.ComponentUtil.fireEvent(
        at com.vaadin.flow.component.internal.AbstractFieldSupport.setValue(
        at com.vaadin.flow.component.internal.AbstractFieldSupport.setModelValue(
        at com.vaadin.flow.component.AbstractField.setModelValue(
        at com.vaadin.flow.component.AbstractSinglePropertyField.handlePropertyChange(
        at com.vaadin.flow.component.AbstractSinglePropertyField.access$200(
        at com.vaadin.flow.component.AbstractSinglePropertyField$1.propertyChange(
        at com.vaadin.flow.internal.nodefeature.ElementPropertyMap.lambda$fireEvent$2(
        at java.base/java.util.ArrayList.forEach(
        at com.vaadin.flow.internal.nodefeature.ElementPropertyMap.fireEvent(
        at com.vaadin.flow.internal.nodefeature.ElementPropertyMap.access$100(
        at com.vaadin.flow.internal.nodefeature.ElementPropertyMap$
        at com.vaadin.flow.server.communication.ServerRpcHandler.runMapSyncTask(
        at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$0(
        at java.base/java.util.ArrayList.forEach(
        at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(
        at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(
        at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(
        at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(
        at com.vaadin.flow.server.VaadinService.handleRequest(

I find this line of code to be the offender… if (!this.locale.equals(locale)) { in UI.class (line:734). This is invoked by getUIs().forEach(ui -> ui.setLocale(locale)); in VaadinSession.class (line:365). While I am still a newbie to completely wrap my head around the internal framework, I suspect the UI instances being iterated over do not have class level attribute locale populated. From the UI code (offending line), it seems that this value must be present for all UI instances.

I would like to know if there are structural prerequisites that I had missed, which could be potentially causing this issue? Or if the components are yet to keep pace with the core framework? If so, is there a workaround or alternate for this functionality? How do I get things working on Vadin 14?


Based on your two questions I assume that there is a problem with the locale.

Can you add System.out.println(Locale.getDefault()); in your application and post what is printed?

Hi Sathyanarayanan

I’m the author of that LanguageSelect add-on. The fact that it works upon first page load means that you did basically all of the setup for that component right already.
Based on your stacktrace, your UI seems to have no locale set in the first place, just like you suspected yourself. I believe this is done automatically by the returned value of I18NProvider::getProvidedLocales. Can you check if your implementation of that method returns the list of Locales that you have translations for?

Check out [Vaadin I18N localization]
( for more info