NPEs in Playback

  • Rob Davison

    Rob Davison - 2008-07-01

    Hi KD and Marathon users.

    Sorry for cross-posting... I originally made some posts in the 'bugs' list, although it doesn't look like that is used much anymore, so I have reposted here.

    I have two null pointer exceptions during playback. I have tried adding sleep(x) before and after, but this does not cure the issue.

    This was first mentioned by bcp2001 here

    Has anyone else experienced this? Is there a resolution/workaround?

    From my original post here
    Again, tried to add sleep(x).
    This one happens in different places during playback, so its a little odd.

    at javax.swing.plaf.basic.BasicMenuItemUI.paint(
    at javax.swing.JComponent.paintComponent(
    at javax.swing.JComponent.paint(
    at javax.swing.JComponent.paintChildren(
    at javax.swing.JComponent.paint(
    at javax.swing.JComponent.paintWithOffscreenBuffer(
    at javax.swing.JComponent.paintDoubleBuffered(
    at javax.swing.JComponent._paintImmediately(
    at javax.swing.JComponent.paintImmediately(
    at javax.swing.RepaintManager.paintDirtyRegions(
    at java.awt.event.InvocationEvent.dispatch(
    at java.awt.EventQueue.dispatchEvent(
    at java.awt.EventDispatchThread.pumpEvents(
    at java.awt.EventDispatchThread.pumpEvents(

    Marathon is a great product, but as you can imagine, we can't run an overnight regression batch at the moment as a few of these NPEs at the beginning of a test will cause the remainder of it to fail!

    Once again, sorry for cross-posting and thanks for your help in advance :-)

    • Rob Davison

      Rob Davison - 2008-07-02

      Hmm, I think issue 1) has been asked on the JGoodies forum here:
      So I have asked this user if the workaround was successful.

    • Dario Novakovic

      Dario Novakovic - 2008-07-03

      Hi all,

      I don't understand if problem 1) or 2) are related (caused by the same bug) but I also get NPE when testing my app which opens screen forms on menu selection. What is most strange is that it not occurs every time, sometimes test replay works fine and most of the time it breaks as soon as it selects menu item. I get 3 kinds of NPE:

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicMenuItemUI.doClick(
          at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicGraphicsUtils.isLeftToRight(
          at javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicMenuItemUI.getMenuItemParent(
          at javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(

      I get the same exceptions with my app and with swing demo apps that use menus.

      So you say that this may be JGoodies problem after all? Would it help if Marathon L&F is set to Java's default L&F? I would try it but I am afraid that some Marathon functionality may be tied to JGoodies. Can anyone from Marathon dev team comment on L&F change?



    • Dakshinamurthy Karra

      SF is having some weird problems and not forwarding the mails to my gmail account. So the monitoring of the forum is some what of a pain as of now.

      The problem is that I was not able to reproduce the NPEs. Can you post a sample where I can reproduce the same? Marathon should not launch the AUT with looks enabled. I think over a period of time that was relaxed a little bit, and Marathon AUT runner is also using the looks at some places. I will check it out and try to remove the dependency. This, to me, seems to be a complete fix.

      Thanks and Regards

    • Dario Novakovic

      Dario Novakovic - 2008-07-04

      Hello KD,

      Here are couple of hints how to reproduce the problem. I tested Metalworks application from JDK demos, it is very simple marathon project setup. I recorded a test using default fixture. Test opens "File" menu and selects "New", at that point exception is thrown. L&F of AUT is default Ocean, so it is not changed by marathon. Here is my test:


      def test():
          java_recorded_version = '1.6.0_04'

          if window('Metalworks'):
              select('TextField', '')
              select('TextField1', 'test')
              select('TextArea', 'lorem ipsum...')

      There is no point to post project properties, they are very simple and contain only classpath, working dir and java  executable. Marathon version is 1.2. I hope this will help you reproduce the problem.

      Thank you for your time!


    • Rob Davison

      Rob Davison - 2008-07-04

      Hi All,

      With regards to issue 1) I contacted the user who reported this on the JGoodies forum. His workaround was this:

      See the classes ExtBasicMenuUI and ExtBasicMenuItemUI in the
      com.jgoodies.looks.common. The methods getPreferredMenuItemSize and
      paintMenuItemm, both classes, rely on the mentioned renderer.

      Insert the following in both methods of both classes (4 times):

      if (renderer == null) {
      System.err.println("Renderer is null!");

      We recompiled the JGoodies lib and so far so good. However we occasionally get this exception instead:

              at javax.swing.plaf.basic.BasicMenuItemUI.doClick(
              at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(
              at java.awt.Component.processMouseEvent(
              at javax.swing.JComponent.processMouseEvent(
              at java.awt.Component.processEvent(
              at java.awt.Container.processEvent(
              at java.awt.Component.dispatchEventImpl(
              at java.awt.Container.dispatchEventImpl(
              at java.awt.Component.dispatchEvent(
              at java.awt.EventQueue.dispatchEvent(
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(
              at java.awt.EventDispatchThread.pumpEvents(
              at java.awt.EventDispatchThread.pumpEvents(

      The basic code is right clicking on table entries and selecting an item from the menu:

      select('TabbedPane', '<html><center><b>Results Detail</b><sup><font size=-3 color=red></html>')
              select('NiceTable', 'cell:Name,4(Company name)')
              rightclick('NiceTable', 'Name,4')
              select('NiceTable', 'cell:Name,4(Company name)')

              if window('Chart'):

              select('NiceTable', 'cell:Name,7(Company name)')
              rightclick('NiceTable', 'Name,7')
              select_menu('Create Chart>>Today')
              select('NiceTable1', 'cell:Name,7(Company name)')

              if window('Importing data'):


      With issue 2 (leftToRight exception) this also occurs much less with the workaround. This is simply from selecting an item from a main menu.

      So the JGoodies fix has almost resolved my issues, but if KD can also disable the looks that would be appreciated.

      Thanks for your time guys.

    • John

      John - 2008-07-08

      I attempted the suggested JGoodies fix with no luck, however I have noticed that adding/increasing delays between the PostEvent calls in the 'fire' function of the file reduces the frequency with which I run into problems.  I suspect that there is a race condition between the postEvent calls, and sub-events fired off by the postEvent calls.  If the sub-events do not fire before the remaining postEvents, then they may not have run the installUI function in BasicMenuItemUI.class, which sets the menuItem variable to a non-null value.  If menuItem is still null when the MouseEvent.MOUSE_RELEASED is fired, it throws a nullPointerException.
      Although adding delays between the postEvents does reduce the frequency of the problem, it does not solve the underlying issue, which is the race condition.  To truly solve this problem, there would need to be some way to guarantee that all sub-events of MouseEvent.MOUSE_PRESSED had completed before MouseEvent.MOUSE_RELEASED was posted, and that all of its sub-events completed before the next event was posted, etc.

    • jason

      jason - 2008-07-09

      I recently upgraded from marathon 1.1.3 to marathon 1.2.0 and have found that when clicking twice in succession or double clicking on a component custom component I created which extends JTree will always produce this NPE.

      SEVERE: !!! Uncaught Exception in Thread AWT-EventQueue-0: java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicTreeUI.paintRow(Unknown Source)
          at javax.swing.plaf.basic.BasicTreeUI.paint(Unknown Source)
          at javax.swing.plaf.ComponentUI.update(Unknown Source)
          at javax.swing.JComponent.paintComponent(Unknown Source)
          at javax.swing.JComponent.paint(Unknown Source)
          at javax.swing.JComponent.paintToOffscreen(Unknown Source)
          at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
          at javax.swing.RepaintManager.paint(Unknown Source)
          at javax.swing.JComponent._paintImmediately(Unknown Source)
          at javax.swing.JComponent.paintImmediately(Unknown Source)
          at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
          at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
          at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
          at javax.swing.SystemEventQueueUtilities$ Source)
          at java.awt.event.InvocationEvent.dispatch(Unknown Source)
          at java.awt.EventQueue.dispatchEvent(Unknown Source)
          at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at Source)

      any suggestions on how to overcome this issue would be greatly appreciated.

      • Dakshinamurthy Karra

        Is it happening during recording or playing?

        -- KD

    • jason

      jason - 2008-07-10

      This is only happening during play back. I tried writing a resolver to extend the MTree with println statements in each of the methods. the NPE occurs after “getComponent()” is called. I don’t think that the error is how component is getting resolved not sure what to try next. if you have any suggestions on how to debug marathon code better then using println statements it would be very helpful. Thxs.

      • Dakshinamurthy Karra

        Better way is to test it using unit tests. The problem with Marathon is that it launches a VM to run the AUT, so using a debugger we can't test the VM that is running the AUT. But the UTs can be debugged that way.

        -- KD

        PS: You should be able to import Marathon as a project into eclipse.

    • united

      united - 2008-07-25

      Hi everyone,

      I manage to fix the NPE problems encountered during playback:

      If you look at the class in the source code you will find at line 375 Marathon calls java to update the ui. I disabled this option and recompiled the code and ran the tests and they all work fine now. See my solution below:

              new FireableMouseClickEvent(getComponent(), numberOfClicks, (modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0)
                      .fire(position, numberOfClicks, modifiers);
              if (true)
                  System.err.println("WARNING: Marathon's updateUI call in MComponent disabled");
              else if (getComponent() instanceof JComponent)
                  ((JComponent) getComponent()).updateUI();

      I don't know why were were calling updateUI() on the components why is it there even in the first place it would be nice to know.



      • Dakshinamurthy Karra

        It was there from long time - I myself do not know why it is there. One reason it was overlooked is because I was confident that the NPE was because of some Swing/Looks issue. That shows why we should not be confident of our own code ;-).

        -- KD

    • Dakshinamurthy Karra

      This is good news indeed and worth a new release :-).

      Can someone else who have the access to the code and having the same problem confirm this?

      -- KD

    • Rob Davison

      Rob Davison - 2008-07-25

      Hi KD and Mustafa - thanks for this fix.

      We shall compile the code now and give it a go. The only way we can tell for sure is by running a large batch of files (can take a few hours...)

      KD - will the issue with 1.4 playback option be in your next release? (



    • Rob Davison

      Rob Davison - 2008-07-25

      Hi All,

      So far, so good - not one NPE. I'll run a full regression over the weekend to make sure.

      Many many thanks for this!!


      • Dakshinamurthy Karra

        Any update?

        -- KD

        • Rob Davison

          Rob Davison - 2008-07-29

          No NPEs over the last few days, so appears to be fixed for me :-)

          • Dakshinamurthy Karra

            Nice to hear that.

            Thanks should go to mustafa :)

            -- KD


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks