Community
Participate
Working Groups
I am facing a strange problem, Eclipse hangs while building as a part of auto build. For this I am using exnternal tool. I have got a build.xml where I have written all compiler steps, and I have changed same .project file also to invoke my build tool only. For build or rebuild of a project goes smooth and I do not have any problem. But during auto build (when you change a source file & save), it hangs. I noticed that in both scenario it uses different Monitor (IProgressMonitor) 1. For build/rebuild - DialogProgressMonitor 2. For autobuild - EventLoopProgressMonitor It looks like that there is something wrong with EventLoopProgressMonitor, I guess thread are not closed, and wiat for ever. Please find the .project and build.xml file. <?xml version="1.0" encoding="UTF-8"? <projectDescription> <nameTest</name> <comment</comment> <projects> </projects> <buildSpec> <buildCommand> <nameorg.eclipse.ui.externaltools.ExternalToolBuilder</name> <arguments> <dictionary> <key!{tool_args}</key> <value</value> </dictionary> <dictionary> <key!{tool_loc}</key> <value${workspace_loc:/Test/build.xml}</value> </dictionary> <dictionary> <key!{tool_dir}</key> <value</value> </dictionary> <dictionary> <key!{tool_refresh}</key> <value${none}</value> </dictionary> <dictionary> <key!{tool_name}</key> <valueext</value> </dictionary> <dictionary> <key!{tool_type}</key> <valueorg.eclipse.ui.externaltools.type.ant</value> </dictionary> <dictionary> <key!{tool_show_log}</key> <valuetrue</value> </dictionary> </arguments> </buildCommand> </buildSpec> <natures> <natureorg.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> <?xml version="1.0" encoding="UTF-8"?> <project name="test" default="compile" basedir="."> <target name="compile" > <exec dir="." executable="javac" > <arg line=" xyz.java" /> </exec> </target> </project>
After blocking the EventLoopProgressMonitor ( monitor.cancel(true), and monitor.done()), and created new DialogProgressMonitor for building, and it goes fine.
We had problems with hanging in 2.0.1...is it possible for you to try 2.0.2. A fix was introduced and it would be great if you could see if this addresses your problem. See bug 25191.
marking as "new" until we have verification this is still a problem.
We tried with Eclipse 2.0.2, and it is working fine if I commnet //monitor.isCanceled(); (blocking cancel functionality). If you will use this, it throws error, SWT.thread error... We are looking for this solution where user can cancel operation anytime. This fix was not made till now. Is there any work around to achieve this?
So you are now getting an SWT error? Can you provide the stack trace?
Please find the stacktrace... org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:2119) at org.eclipse.swt.SWT.error(SWT.java:2051) at org.eclipse.swt.widgets.Display.error(Display.java:503) at org.eclipse.swt.widgets.Display.checkDevice(Display.java:370) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1285) at org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor.runEventLoop (EventLoopProgressMonitor.java:89) at org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor.isCanceled (EventLoopProgressMonitor.java:68) at org.eclipse.core.runtime.ProgressMonitorWrapper.isCanceled (ProgressMonitorWrapper.java:87) at org.eclipse.core.runtime.ProgressMonitorWrapper.isCanceled (ProgressMonitorWrapper.java:87) at org.eclipse.core.runtime.ProgressMonitorWrapper.isCanceled (ProgressMonitorWrapper.java:87) at test.BuildLogger.checkCanceled(BuildLogger.java:354) at test.ant.BuildLogger.messageLogged(BuildLogger.java:217) at org.apache.tools.ant.Project.fireMessageLoggedEvent(Project.java:982) at org.apache.tools.ant.Project.fireMessageLogged(Project.java:998) at org.apache.tools.ant.Project.log(Project.java:250) at org.apache.tools.ant.Task.log(Task.java:207) at org.apache.tools.ant.taskdefs.LogOutputStream.processLine (LogOutputStream.java:132) at org.apache.tools.ant.taskdefs.LogOutputStream.processLine (LogOutputStream.java:123) at org.apache.tools.ant.taskdefs.LogOutputStream.processBuffer (LogOutputStream.java:113) at org.apache.tools.ant.taskdefs.LogOutputStream.write (LogOutputStream.java:103) at java.io.OutputStream.write(OutputStream.java:102) at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:100) at java.lang.Thread.run(Thread.java:484)
The SWT error is an error in your code. SWT enforces that all access to its widgets/state be only from the designated UI thread. The coding style to workaround this limitation is to make use of Display.asyncExec(Runnable) and Display.syncExec(Runnable). See the comments on these methods for more details (or some of the many SWT snippet examples)
After doing above change it works fine without any problem.
Fixed in 2.0.2. No plans for any additional work.