Exception! A connector should not be marked as dirty while a response is b

I try to load a tree with an SQLConnector, which gives me the above exception.
my Code:
HierarchicalSQLContainer container = null; this.getSession().getLockInstance().lock(); try { container = GetQueryContainerTest("MenuTree"); navTree.setContainerDataSource(container); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ this.getSession().getLockInstance().unlock(); } The Exception stack is as follow:

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:412) at com.vaadin.server.AbstractClientConnector.markAsDirty(AbstractClientConnector.java:140) at com.vaadin.ui.Tree.markAsDirty(Tree.java:301) at com.vaadin.ui.AbstractSelect.fireItemSetChange(AbstractSelect.java:1712) at com.vaadin.ui.AbstractSelect.containerItemSetChange(AbstractSelect.java:1679) at com.vaadin.ui.Tree.containerItemSetChange(Tree.java:940) at com.vaadin.data.util.sqlcontainer.SQLContainer.fireContentsChange(SQLContainer.java:1628) at com.vaadin.data.util.sqlcontainer.SQLContainer.refresh(SQLContainer.java:911) at com.vaadin.data.util.sqlcontainer.SQLContainer.refresh(SQLContainer.java:893) at com.vaadin.data.util.sqlcontainer.SQLContainer.addContainerFilter(SQLContainer.java:550) at de.fuchclan.data.HierarchicalSQLContainer.rootItemIds(HierarchicalSQLContainer.java:38) at com.vaadin.ui.Tree.rootItemIds(Tree.java:863) at com.vaadin.ui.Tree.paintContent(Tree.java:630) at com.vaadin.server.LegacyPaint.paint(LegacyPaint.java:65) at com.vaadin.server.communication.LegacyUidlWriter.write(LegacyUidlWriter.java:82) at com.vaadin.server.communication.UidlWriter.write(UidlWriter.java:116) at com.vaadin.server.communication.UIInitHandler.getInitialUidl(UIInitHandler.java:290) at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:80) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1406) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Does someone has an idea how to solve this?
thanks
Gerald

Gerald-

Check out
link
to see if that helps out.

Regards,
Eric

Hi Eric,
I did find this before, and added the followig code, but it did not help.

HierarchicalSQLContainer container = null;
        this.getSession().getLockInstance().lock();
        try {
            container = GetQueryContainerTest("MenuTree");
            navTree.setContainerDataSource(container);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        finally{
            this.getSession().getLockInstance().unlock();
        }

Try:

UI.getCurrent().getSession().getLockInstance() That should provide the locking mechanism needed.

Regards,
Eric

Hi Eric,
I changed it based on your recomendation to:

HierarchicalSQLContainer container = null; UI.getCurrent().getSession().getLockInstance().lock(); try { container = GetQueryContainerTest("MenuTree"); navTree.setContainerDataSource(container); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ UI.getCurrent().getSession().getLockInstance().unlock(); } But I still get the exception
A connector should not be marked as dirty while a response is being written.

When I use the container on a table, then it works fine. Only on a tree I have this issue.

Hi,
did you resolve this error?

I’m getting it while pushing a String to a textarea which is being built from the answers (server messages) from a REST client running in another thread (or else the UI will lock up) during a process which is being executed on another server.
This process goes on for a few minutes and can potentially take up to one hour.
The try catch clause and locking/unlocking the instances didn’t work for me either.

On rare occasions the error won’t appear and everything will work out properly, but most of the time I will get this exact error.

Currently I kinda trick the other thread to continue running by just catching the error and executing the field update again inside the catch block:

public void updateText(){
    try {
        progresstext.setValue(getProgress());
        progresstext.setCursorPosition(progresstext.getValue().length());
    } catch (Exception e) {
        log.error("vaadin connector error: ", e);
        updateText();
    }
}

I’ve done a few test runs and sometimes the error gets caught twice, but I don’t think this should lead to a lock.

BR

Try following:

ui.access(new Runnable() { @Override public void run() { progresstext.setValue(getProgress()); progresstext.setCursorPosition(progresstext.getValue().length()); } }); (See
Server Push
for more info).

I had a similar problem when I use a container in more than one component. I my case there were two ComboBoxes which share the same container and when I start typing to select in one ComboBox, the OTHER get containerItemSetChange() calls with isPainting=false, call super.containerItemSetChange(event) and cause this error.
I fixed the problem by creating separate containers for both components.