Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
ArrayIndexOutOfBoundsException when using restartApplication url
Hi All,
I am getting an ArrayIndexOutOfBoundsException when I use the ?restartApplication url as explained below.
I have a SettingsWindow class that extends Window:
public class SettingsWindow extends Window {
@Autowired
private QueryliteService queryliteService;
...
public SettingsWindow() {
setWidth("600px");
setHeight("500px");
setModal(true);
center();
setDraggable(false);
setResizable(false);
...
VerticalLayout driverSettingsLayout = new VerticalLayout();
driverSettingsLayout.setSizeFull();
Component driverSettings = getDriverSettings();
driverSettingsLayout.addComponent(driverSettings);
...
}
private Component getDriverSettings() {
...
Tree driversTree = new Tree("");
buildDriversTree(driversTree);
leftSidebar.addComponent(driversTree);
driversTree.setSizeFull();
...
}
private void buildDriversTree(Tree driversTree) {
driversTree.removeAllItems();
for(int i=1;i<10;i++) {
driversTree.addItem("driver" + i);
}
}
}
With the above code, the application works fine. I can open the SettingsWindow and it shows me the tree with the items driver0 to driver9. I can restart the application using the ?restartApplication url without any problem.
However, if I change the buildDriversTree method as shown below :
private void buildDriversTree(Tree driversTree) {
driversTree.removeAllItems();
List<DriverType> driverTypes = queryliteService.getAllDriverTypes();
for(DriverType driverType : driverTypes) {
driversTree.addItem(driverType.getName());
}
}
The application starts and works fine. I can open the SettingsWindow and it shows me the tree with the items from the database. But when I use the ?restartApplication url, it fails with the following exception:
SEVERE: Servlet.service() for servlet [Querylite Vaadin Application Servlet] in context with path [/querylite] threw exception
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:334)
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:347)
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:425)
at org.apache.tomcat.util.http.Parameters.handleQueryParameters(Parameters.java:189)
at org.apache.catalina.connector.Request.parseParameters(Request.java:2993)
at org.apache.catalina.connector.Request.getParameter(Request.java:1139)
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:382)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.isRepaintAll(AbstractApplicationServlet.java:2341)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:427)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Is there something wrong with the way I am handling the tree component with dynamic data as opposed to static data?
I can't spot any problem with your code. Furthermore, the stacktrace indicates that your Tomcat has some serious problem as it dies on a simple call to HttpServletRequest.getParameter. I found some similar Tomcat bugs that have been fixed many years ago so this shouldn't be the cause if you're using Tomcat 6 or Tomcat 7.
Some reports seem to suggest that some similar Tomcat problems might be related to big headers or a very long query string in the request. None of those things seem to be related to how you are populating the tree.
On thing that you could check is if the call to queryliteService.getAllDriverTypes() by itself has any side effects that happen even if you don't add the data to the Tree (nor any other Vaadin component).
Another option is if the data you get from driverType.getName() contains some weird (possibly invisible) characters that trigger might trigger some obscure bug in Vaadin or in Tomcat.