Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7193739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:13:52+00:00 2026-05-28T20:13:52+00:00

We are building an application based on the Netbeans Platform, and one part of

  • 0

We are building an application based on the Netbeans Platform, and one part of it is an editor for a specific language we use.

We have the following class to highlight errors in the syntax:

class SyntaxErrorsHighlightingTask extends org.netbeans.modules.parsing.spi.ParserResultTask {

public SyntaxErrorsHighlightingTask () {
}

@Override
public void run (org.netbeans.modules.parsing.spi.Parser.Result result, org.netbeans.modules.parsing.spi.SchedulerEvent event) {
    try {
        final javax.swing.text.Document document = result.getSnapshot().getSource ().getDocument(false);
        final List<ErrorDescription> errors = new ArrayList<ErrorDescription> ();
        // finds errors on the document and add them to 'errors' list
        }

        /***
        OFFENDING CODE GOES HERE
        ***/

    } catch (javax.swing.text.BadLocationException ex1) {
        org.openide.util.Exceptions.printStackTrace (ex1);
    } catch (org.netbeans.modules.parsing.spi.ParseException ex1) {
        Exceptions.printStackTrace (ex1);
    }
}

@Override
public int getPriority () {
    return 100;
}

@Override
public Class<? extends Scheduler> getSchedulerClass () {
    return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER;
}

@Override
public void cancel () {
}

}

The offending code, that throws an exception, is this:

org.netbeans.spi.editor.hints.HintsController.setErrors (document, "testsequence", errors);

Based on searching results, it was changed to the following:

SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                     System.err.println("is EDT? " + SwingUtilities.isEventDispatchThread());
                     HintsController.setErrors (document, "testsequence", errors);
                }
           });

The following is what happens when a syntax error is introduced in the editor:

is EDT? true
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.spi.editor.hints.HintsController$1
java.lang.IllegalStateException: Must be run in EQ
    at org.netbeans.editor.Annotations.addAnnotation(Annotations.java:195)
    at org.netbeans.modules.editor.NbEditorDocument.addAnnotation(NbEditorDocument.java:251)
    at org.openide.text.NbDocument.addAnnotation(NbDocument.java:504)
    at org.netbeans.modules.editor.hints.AnnotationHolder$NbDocumentAttacher.attachAnnotation(AnnotationHolder.java:235)
    at org.netbeans.modules.editor.hints.AnnotationHolder.attachAnnotation(AnnotationHolder.java:208)
    at org.netbeans.modules.editor.hints.AnnotationHolder.updateAnnotationOnLine(AnnotationHolder.java:674)
    at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptionsImpl(AnnotationHolder.java:899)
    at org.netbeans.modules.editor.hints.AnnotationHolder.access$1300(AnnotationHolder.java:113)
    at org.netbeans.modules.editor.hints.AnnotationHolder$4.run(AnnotationHolder.java:812)
    at org.netbeans.editor.BaseDocument.render(BaseDocument.java:1409)
    at org.netbeans.modules.editor.hints.AnnotationHolder.setErrorDescriptions(AnnotationHolder.java:809)
    at org.netbeans.modules.editor.hints.HintsControllerImpl.setErrorsImpl(HintsControllerImpl.java:111)
    at org.netbeans.modules.editor.hints.HintsControllerImpl.setErrors(HintsControllerImpl.java:93)
    at org.netbeans.spi.editor.hints.HintsController$1.run(HintsController.java:79)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1968)
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to
    at org.openide.util.RequestProcessor.post(RequestProcessor.java:425)
    at org.netbeans.spi.editor.hints.HintsController.setErrors(HintsController.java:77)
    at com.#.#.#.editor.parser.SyntaxErrorsHighlightingTask$1.run(SyntaxErrorsHighlightingTask.java:74)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:602)
    at java.awt.EventQueue$1.run(EventQueue.java:600)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

What happens is, the call is to HintsController is being made in the EDT (EventDispatch Thread). However, Annotations.addAnnotation() is being run in another thread – sometimes in the “System clipboard synchronizer” thread, sometimes in the “Inactive RequestProcessor” thread. Since it checks if its being run on the EDT, it always throws an IllegalStateException.

I’m no expert in using the Netbeans Platform, and I’m pretty new to this specific application on the company – so I might be missing something really obvious. Google didn’t help much. Anyone has any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:13:53+00:00Added an answer on May 28, 2026 at 8:13 pm

    Turns out, it was not a problem with the code after all.

    As pointed on the NetBeans-dev list:

    HintsController.setErrors can be called from any thread – it uses its
    own worker thread, and reschedules to AWT thread when necessary.

    The requirement to invoke Annotations.addAnnotation in AWT thread has
    been removed quite some time ago by:
    http://hg.netbeans.org/main-silver/rev/db82e4e0fbcc

    The same changeset also removed automatic rescheduling into AWT thread
    in NbDocument.addAnnotation. So it seems that the build you are using
    has the second part of the changeset, but not the first part (…)

    After a careful review of maven’s pom.xml files, I realized that the application was loading newer versions of the libs while the module was loading older versions, so it would run the wrong code. Related SO question about that here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a internationalized application based of Java using Netbeans IDE, I´m trying to
We're building an application designed to run on Windows-based servers. One of the considerations
I'm building a new ASP.NET web application based on a legacy one (Classic ASP).
I am currently building a RCP application based on Eclipse. In one of my
I am building a web based application written in ASP.NET and Flex. One of
I'm building a web-based application that can use ActiveX Controls to print to a
I am building a PHP comet based application. Which web server should I use
I am building a web-based application. The frontend has been designed in Sproutcore. For
I'm building an Android application that's based around an enhanced WebView (based on PhoneGap).
I'm building a simple web based forum application. I want to allow users to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.