Error on table sorting after a filter...

I’ve an error (!) that appears when sorting a table (clicking on a column header).

This error (see below), appears only in the following case :

If I sort my ‘raw’ datas : no problem
If I apply a filter, then click on a column, the error indicator appears beside the table showing the following message :

	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.mergeSort(
	at java.util.Arrays.sort(
	at java.util.Collections.sort(
	at com.vaadin.ui.Table.sort(
	at com.vaadin.ui.Table.sort(
	at com.vaadin.ui.Table.changeVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(

Finally, if I enable the column collapsing and the column reordering, I obtain an ‘internal error’ with red popup…

is this a bug …?


ps : I use VAADIN 6.2.1, with the latest eclipse plugin

Well… Am I the only one to have this problem ?

In that case I must suppose that I’m doing something wrong…:unsure:

Or maybe it’s related with the datas inside the table ?

The internal error is a result of the NullPointerException. The cause of the NPE could be that the container returns “null” instead of a Property object for some propertyId. Set a NullPointerException breakpoint in your IDE and you will see what the cause is. I would guess it has something to do with the container you are using.

I’m afraid I need more advices…

I know where’s the problem, but I don’t know how to solve it.
the NPE is caused by the following line :

 protected int compareProperty(Object propertyId, boolean sortDirection,
            Item item1, Item item2) {

        // Get the properties to compare
        final Property property1 = item1.getItemProperty(propertyId);  <=== THIS ONE
        final Property property2 = item2.getItemProperty(propertyId);

        // Get the values to compare
        final Object value1 = (property1 == null) ? null : property1.getValue();
        final Object value2 = (property2 == null) ? null : property2.getValue();

Because, both item1 and item2 are null… So of course I get a NPE…
But I can’t understand why are they null !

I’m creating myself the container: an indexedContainer. And before going on the sort process, I can see that all my items in the container are Ok (no null…).

So, I’m surely doing something wrong when initializing the container, but I can’t see what…

Do you have any idea or clue for me…?


A good example is always better : please consider the following program :

import com.vaadin.Application;
import com.vaadin.ui.*;

public class Main extends Application {

	IndexedContainer ic = generateContainer();
	Label label = new Label("Hello Vaadin user");
	TextField text = new TextField ("Filter");
	Table table = new Table();

	public void init() {
		Window mainWindow = new Window("Isis_tri Application");




	public void changeText () {
		ic.addContainerFilter("Last Name", text.getValue().toString(), true, false);
	private IndexedContainer generateContainer() {

		String [] fields = { "First Name","Last Name" };

		String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia",
				"Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene",
				"Lisa", "Marge" };
		String[] lnames = { "Smith", "Gordon", "Simpson", "Brown", "Clavel",
				"Simons", "Verne", "Scott", "Allison", "Gates", "Rowling",
				"Barks", "Ross", "Schneider", "Tate" };

		IndexedContainer ic = new IndexedContainer();

		for (String p : fields) {
			ic.addContainerProperty(p, String.class, "");

		for (int i = 0; i < 1000; i++) {
			Object id = ic.addItem();
			ic.getContainerProperty(id, "First Name").setValue(
					fnames[(int) (fnames.length * Math.random())]
			ic.getContainerProperty(id, "Last Name").setValue(
					lnames[(int) (lnames.length * Math.random())]

		return ic;


It is just a text field + a table.
You type a text in the textfield,then the table is filtered with the value typed on the column ‘Last Name’

After doing this, if I try to sort on any column, I get an internal error (see first message).

What am I doing wrong ?

Ok, now I see what the problem is and it is a bug in the item sorter. I created
a ticket
for it.

Ok, thanks,

By the way, I get the same error if the resulting container is empty (after applying the filter) .

but I suppose it’s more or less the same case.