UI can not be null

I am working on migrating a currently working legacy VAADIN app from one environment to another. The same webapp from the working environment is throwing a “java.lang.IllegalArgumentException: UI can not be null” in tomcat-stderr. I am new to VAADIN and only trying to migrate this app, not re-build it from source code. Could someone point me in the right direction as to why this error would occur in one env but not another with the same code?
Verified the servers are setup with the same version of Java and tomcat. VAADIN version 8.3.1

Hi @John_Harrison,

Can you share more information? The full stacktrace would help pinpoint what might be the issue here.

Are you using the IdleAlarm add-on? That contains the “UI can not be null” text verbatim, here: IdleAlarm/idlealarm-addon/src/main/java/org/vaadin/alump/idlealarm/IdleAlarm.java at master · alump/IdleAlarm · GitHub

Assuming you’re using the parameter-less get() method, in that case UI.getCurrent() must return null, which occurs when you’re outside of the normal request thread.

Another option is the unload() method, with similar considerations for UI.getCurrent().

May 02, 2024 8:06:13 AM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
java.lang.IllegalArgumentException: UI can not be null
at org.vaadin.alump.idlealarm.IdleAlarm.unload(IdleAlarm.java:122)
at org.vaadin.alump.idlealarm.IdleAlarm.unload(IdleAlarm.java:113)
at com.hilton.fna.dms.workflow.invoice.ui.InvoiceInboxUI$InvoiceInboxUIServlet.sessionDestroy(InvoiceInboxUI.java:2300)
at com.vaadin.server.VaadinService.lambda$fireSessionDestroy$1(VaadinService.java:554)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.vaadin.server.VaadinService.runPendingAccessTasks(VaadinService.java:2023)
at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1019)
at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1455)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1615)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:445)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:750)

Here’s something in your codebase that you could look into:

com.hilton.fna.dms.workflow.invoice.ui.InvoiceInboxUI$InvoiceInboxUIServlet.sessionDestroy(InvoiceInboxUI.java:2300)

So that line calls IdleAlarm.unload, and at that time, UI.getCurrent() returns null (because the session has probably already been destroyed).

1 Like

This is the request in the browser that fails

http://localhost/InvoiceInbox/UIDL/?v-uiId=0. Cant seem to figure out why this doesnt return properly. I do see this. In the popup when adding ?debug to the url i see an error “Response didn’t contain a server id. Please verify that the server is up-to-date and that the response data has not been modified in transmission.”

Look at the response body in browser developer tools. It’s not a normal Vaadin response; something is failing on roughly the servlet level - maybe the session is dead or the request doesn’t match to a VaadinServlet.