SQLContainer + TwinColSelect gives error

Hello,
I want to use SQLContainer as datasource for TwinColSelect. Here is a small test app:


public class VaadintestUI extends UI {

	@Override
	protected void init(VaadinRequest request) {
		final VerticalLayout layout = new VerticalLayout();
		layout.setMargin(true);
		setContent(layout);

		final TwinColSelect select;
		try {
			
			final SQLContainer ctn = new SQLContainer(
					new FreeformQuery("SELECT * FROM tlusers",
								new SimpleJDBCConnectionPool(
									"org.postgresql.Driver",
									"jdbc:postgresql://localhost/db", "postgres", "postgres", 5, 20),
								new String[] {"sys_id"}));
			
			select = new TwinColSelect("",ctn);
			layout.addComponent(select);
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

When I try to run the app, I get the following error:
A connector should not be marked as dirty while a response is being written.

When I replace the TwinColSelect with the Table component, everything works just fine.

Here the stacktrace:


java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.
	at com.vaadin.ui.ConnectorTracker.markDirty(ConnectorTracker.java:346)
	at com.vaadin.server.AbstractClientConnector.markAsDirty(AbstractClientConnector.java:139)
	at com.vaadin.ui.AbstractSelect.fireItemSetChange(AbstractSelect.java:1679)
	at com.vaadin.ui.AbstractSelect.containerItemSetChange(AbstractSelect.java:1646)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.fireContentsChange(SQLContainer.java:1585)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.refresh(SQLContainer.java:877)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.updateCount(SQLContainer.java:1129)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.getItemIds(SQLContainer.java:326)
	at com.vaadin.ui.AbstractSelect.getItemIds(AbstractSelect.java:728)
	at com.vaadin.ui.AbstractSelect.paintContent(AbstractSelect.java:367)
	at com.vaadin.ui.TwinColSelect.paintContent(TwinColSelect.java:165)
	at com.vaadin.server.LegacyPaint.paint(LegacyPaint.java:65)
	at com.vaadin.server.AbstractCommunicationManager.legacyPaint(AbstractCommunicationManager.java:1323)
	at com.vaadin.server.AbstractCommunicationManager.writeUidlResponse(AbstractCommunicationManager.java:810)
	at com.vaadin.server.AbstractCommunicationManager.getInitialUIDL(AbstractCommunicationManager.java:2528)
	at com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2366)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	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)
14.06.2013 14:26:28 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet [Vaadintest Application]
 in context with path 
[/VaadinTest] threw exception [java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.]
 with root cause
java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.
	at com.vaadin.ui.ConnectorTracker.markDirty(ConnectorTracker.java:346)
	at com.vaadin.server.AbstractClientConnector.markAsDirty(AbstractClientConnector.java:139)
	at com.vaadin.ui.AbstractSelect.fireItemSetChange(AbstractSelect.java:1679)
	at com.vaadin.ui.AbstractSelect.containerItemSetChange(AbstractSelect.java:1646)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.fireContentsChange(SQLContainer.java:1585)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.refresh(SQLContainer.java:877)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.updateCount(SQLContainer.java:1129)
	at com.vaadin.data.util.sqlcontainer.SQLContainer.getItemIds(SQLContainer.java:326)
	at com.vaadin.ui.AbstractSelect.getItemIds(AbstractSelect.java:728)
	at com.vaadin.ui.AbstractSelect.paintContent(AbstractSelect.java:367)
	at com.vaadin.ui.TwinColSelect.paintContent(TwinColSelect.java:165)
	at com.vaadin.server.LegacyPaint.paint(LegacyPaint.java:65)
	at com.vaadin.server.AbstractCommunicationManager.legacyPaint(AbstractCommunicationManager.java:1323)
	at com.vaadin.server.AbstractCommunicationManager.writeUidlResponse(AbstractCommunicationManager.java:810)
	at com.vaadin.server.AbstractCommunicationManager.getInitialUIDL(AbstractCommunicationManager.java:2528)
	at com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2366)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	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)

Any idea what’s going wrong / what I’m doing wrong ?

Best regards,
Matthias

That sounds pretty similar to this thread:
https://vaadin.com/forum#!/thread/2153665

and this ticket:
#10458

Maybe you should create a new ticket or expand the existing one to twinselect.

(Disclaimer: I’m not a Vaadin Dev so i don’t know whether this might already be fixed/planned to be fixed soon)

Thanks for pointing that out. I reopened the ticket.

This issue was split to Bug #12085
http://dev.vaadin.com/ticket/12085
. I have attached a patch there that migiht fix this problem for all components based on AbstractSelection (Table and ComboBox have already slightly different own fixes!), but I cannot shake the feeling that the real problem is either that the IllegalStateException should not be thrown, or calling markDirty should be avoided by other means

See also my comment in respect to the fix in Bug #9444
http://dev.vaadin.com/ticket/9444
, which introduced the IllegalStateException.