Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 17 of 17

Thread: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Hi All,

    My web application will load an applet with SWING components (Menu bar) on successful login to application.

    Once page is loaded, i choose a menu item from the menu bar and click on it. Dynamic menu bar is loaded for the selected menu item. After that i am not able to perform any action on menu bar. Ending up with below error.

    Note: My Application is absolutely working fine till JRE 1.7.17. But when i upgarde to higher version of JRE like 1.7.25 and above i am getting below error.

    Exception in thread "AWT-EventQueue-4" java.lang.NullPointerException
    at javax.swing.RepaintManager.scheduleProcessingRunna ble(Unknown Source)
    at javax.swing.RepaintManager.addDirtyRegion0(Unknown Source)
    at javax.swing.RepaintManager.addDirtyRegion(Unknown Source)
    at javax.swing.JComponent.repaint(Unknown Source)
    at java.awt.Component.repaint(Unknown Source)
    at javax.swing.AbstractButton$Handler.stateChanged(Un known Source)
    at javax.swing.DefaultButtonModel.fireStateChanged(Un known Source)
    at javax.swing.DefaultButtonModel.setRollover(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsMenuUI$Wind owsMouseInputHandler.mouseEntered(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.trackMouseEnterExit (Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Please help me or atleast give me lead when this issue occur. Your help is much appreciated.

    Regards
    Nagesh


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Can you post an SSCCE that demonstrates this behavior?

    You aren't doing anything related to the GUI on another thread are you?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Hi, Thanks for the quick reply. I can not sent SSCCE as it is a huge project.
    As i posted earlier, Java Web Start loads the Applet in IE browser with SWINGS components as menu bar. When i choose a menu item and click on it, application dynamically loads the menu bar for the selected menu item. Then i am seeing this error. I have put all necessay console statements but couldnt find root cause.

    Same is working absolutely fine with JRE 1.7.17. Any higher versions is throwing this error.

    When does this javax.swing.RepaintManager.scheduleProcessingRunna ble(Unknown Source) exceptin thrown while using SWINGS code?

    From the applet's init method:
    public void paint(Graphics g) {
    /**@todo: Override this java.awt.Container method*/
    super.paint( g);

    if (!_hasPainted) {
    _numTimesPainted++;
    if (_numTimesPainted >= _numTimesPaintedThreshhold) {
    _hasPainted = true;
    }
    doInvokeLaters();
    }
    }
    public void invokeLater(Runnable runnable) {
    _runnableList.add(runnable);
    if (_hasPainted) {
    doInvokeLaters();
    }
    }

    protected void doInvokeLaters() {
    while (_runnableList.size() > 0) {
    Runnable runnable = (Runnable)_runnableList.get(0);
    _runnableList.remove(0);
    SwingUtilities.invokeLater(runnable);
    }
    }


    //THis is seconde instance where i am calling EDT
    // if the applet is not the menu applet, get the focus to the applet.
    // This is required if the user tries to do a F5 on the popup screen

    //Added to fix cursor move to popup error - Start
    SwingUtilities.invokeLater(new Runnable()
    {
    public void run()
    {
    getRootPane().requestFocus();
    }
    });

    Let me know if more information is needed.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    At some version, java started returning null for some usages of getCodeBase() and getDocumentBase(). Does your code use either of those methods?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Yes it is using both the methods.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Can you add some debug code that prints out what those methods returns to see if it is null?

    What is done with the values returned by those methods?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    They are constructing the URL
    URL fullURL = new URL(getCodeBase(), relativeURL);
    // Cause the current document to navigate to this new URL
    getAppletContext().showDocument(fullURL);

    I will put console statements and test in the mean while. Thank you.

  8. #8
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by nageshvk View Post
     public void paint(Graphics g) {
            /**@todo: Override this java.awt.Container method*/
            super.paint( g);
     
            if (!_hasPainted) {
                _numTimesPainted++;
                if (_numTimesPainted >= _numTimesPaintedThreshhold) {
                    _hasPainted = true;
                }
                doInvokeLaters();
            }
        }
    public void invokeLater(Runnable runnable) {
            _runnableList.add(runnable);
            if (_hasPainted) {
                doInvokeLaters();
            }
        }
     
        protected void doInvokeLaters() {
            while (_runnableList.size() > 0) {
                Runnable runnable = (Runnable)_runnableList.get(0);
                _runnableList.remove(0);
                SwingUtilities.invokeLater(runnable);
            }
        }
    From this code I see that SwingUtilities.invokeLater can be called in the context of the paint. I don't think this is a good idea. A paint can be called many times and for several reasons. Thus the paint should not be used to apply some specific logic and/or to change some other state of the application.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  9. #9
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Hi,

    You mean calling invokeLater through paint is causing this NullPointerException? If yes, How it is working fine with JRE 1.7.17 and below versions?
    Regards
    Nagesh

  10. #10
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by nageshvk View Post
    You mean calling invokeLater through paint is causing this NullPointerException?
    No ... in the sense that I don't/can't know if this is the cause of the NPE. Simply I noticed your design and pointed out the conceptual issue about that.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  11. #11
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by nageshvk View Post
    Yes it is using both the methods.
    Hi Norm,

    As suggested I have tested the application. getCodeBase and getDocumentBase are not throwing NULL value. Please let me know how to proceed further.

    andbin~ Could you please suggest the design change then?

    Regards
    Nagesh

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    how to proceed further.
    Make a SSCCE that shows the problem and can be used by others for testing.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by nageshvk View Post
    andbin~ Could you please suggest the design change then?
    Unfortunately I don't/can't know why you are using that _runnableList, why you would like to get 1 Runnable from list and dispatch it to the EDT (in the paint context) and what you are trying to do in general.
    Without having a clear overview about your application and your ideas, it's difficult (for me) to answer.

    One thing should be clear: the paint() should paint .... nothing more.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  14. #14
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    The initial value of _runnableList is empty. So Runnable object does not get invoked until the applet has painted itself for the first time. All Listener implementations accross the application calls this invokeLater method by passing a runnable object, whihc inturn calls the doInvokeLater method. Now Runnable objects are iterated and dispatced to the EDT before removing it from the arraylist.

  15. #15
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by nageshvk View Post
    All Listener implementations accross the application calls this invokeLater method by passing a runnable object, whihc inturn calls the doInvokeLater method. Now Runnable objects are iterated and dispatced to the EDT before removing it from the arraylist.
    But .... the one, main question is: why?
    What are you trying/expecting to do?
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  16. #16
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Reason: This design will delay certain EDT actions until the main applet has painted itself for the first time.

    Paint method will never triggers SwingUtilities.invokeLater(runnable) line of code.Note: Default values of _hasPainted is false, _runnableList is empty ArrayList.

    It has following validations:
    1st time: _hasPainted value is false, so it calls doInvokeLaters() method, sets the _hasPainted value to true but _runnableList is empty. Hence EDT is not called.

    2nd time onwards: _hasPainted value is true, so it will not call doInvokeLaters() method itself.

    More over if the design is incorrect, it should not work for any JRE. (Correct me if i am wrong). But it is working fine with JRE 1.7.17 but not with JRE 1.7.51

    Thanks for your reply.

  17. #17
    Junior Member
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AWT EVent Queue Null Pointer Exception while using JRE 1.7.51 as IE browser JRE.

    Quote Originally Posted by Norm View Post
    Can you add some debug code that prints out what those methods returns to see if it is null?

    What is done with the values returned by those methods?


    Hi Norm,

    There was a similar thread which you replied for the issue.
    jre 7u45 Applet has an exception

    I am unable to produce same exception with a sample program. Could you please suggest a workaround if you have any.

    Regards
    Nagesh

Similar Threads

  1. [SOLVED] Priority Queue Null Pointer Exception
    By OverZealous in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 14th, 2013, 02:52 PM
  2. Replies: 3
    Last Post: May 16th, 2013, 09:17 AM
  3. Null Pointer Exception?
    By SeanEE89 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 16th, 2011, 06:21 PM
  4. Null pointer exception
    By Wrathgarr in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 23rd, 2010, 12:48 AM
  5. Null Pointer Exception
    By MysticDeath in forum Exceptions
    Replies: 2
    Last Post: October 24th, 2009, 01:49 PM