No Such Element Exception

  • I am having a problem which is odd enough that I wanted to discuss before creating a GitHub issue. I am having problem with scenarios that I have extracted in order to edit. In 2 different scenarios I receive the NoSuchElementException and the following error in the debug console. The second error repeats multiple times.The map in one scenario has some large rectangular blank errors and the other scenario only on small part of the map is drawn. Other extracted scenarios work fine.

    at games.strategy.triplea.ui.mapdata.DefaultColors.nextColor(
    at games.strategy.triplea.ui.mapdata.MapData.getPlayerColor(
    at games.strategy.triplea.ui.screen.SmallMapImageManager.update(
    at java.desktop/java.awt.event.InvocationEvent.dispatch(
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(
    at java.desktop/java.awt.EventQueue$
    at java.desktop/java.awt.EventQueue$
    at java.base/ Method)
    at java.base/$JavaSecurityAccessImpl.doIntersectionPrivilege(
    at java.desktop/java.awt.EventQueue.dispatchEvent(
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(
    at java.desktop/

    May 03, 2020 4:16:49 PM lambda$initializeClientSettingAndLogging$0
    SEVERE: null
    at games.strategy.triplea.ui.mapdata.DefaultColors.nextColor(
    at games.strategy.triplea.ui.mapdata.MapData.getPlayerColor(
    at games.strategy.triplea.ui.screen.drawable.BattleDrawable.draw(
    at games.strategy.triplea.ui.screen.Tile.draw(
    at games.strategy.triplea.ui.screen.Tile.drawImage(
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.base/java.util.concurrent.ThreadPoolExecutor$
    at java.base/

  • Admin

    @RogerCooper It appears you have a map that is relying on default player colors where you have more than 8 players and there are only 8 defaults defined in TripleA. If you edit the map to define player colors for all players or all but 8 or less, it should work.

  • @redrum Here is the file. Is there somewhere else I need to define the colors?

    #Color settings for the map, values must be in 6 digit hex form

    map.height= 2000

    should we draw territory names


  • Admin

    @RogerCooper That looks fine. Either it isn't reading your properties file or you have lots of other players with their colors defined. If you send me the map, I can take a look.

  • @redrum
    Note that there are no other players at all.

  • Moderators

    @RogerCooper Do the other errors that repeat equal all the players listed in the properties file?

  • @Hepps The error repeats many times, far more than 6.

    I was able to fix the problem with the other scenario (I was missing a player in

    Note that small portion of the map is displayed with colors.


  • Admin

    @RogerCooper It loads fine for me. Can you double check that you don't have multiple versions of it in your maps folder?

  • @redrum Only 1 version. It does not work for me when zipped either.

  • Admin

    @RogerCooper Hmm. And you are using or a pre-release version? I just tested with with the zipped map and see this:

  • @redrum I am using the prerelease (19049)

  • Admin

    @redrum Nice to hear that the stacktraced seems to be cause by such a "simple" problem, but I found the stacktrace super confusing nevertheless.
    Would it be easy to add some sort of pre-condition so we would fail to parse a map when the engine noticed there aren't enough default colors? I think a simpler error message would be desirable here.

  • The NoSuchElementException in Java is thrown when one tries to access an iterable beyond its maximum limit. This means that, this exception is thrown by various accessor methods to indicate that the element being requested does not exist . The next() method in Java returns the next element in the iteration or NoSuchElementException if the iteration has no more elements.

    As with most programming languages, the Iterator class includes a hasNext() method that returns a boolean indicating if the iteration has anymore elements. If hasNext() returns true, then the next() method will return the next element in the iteration otherwise raise exceptions if the iteration has no more elements.

    if(input.hasNextInt() )
         number1 = input.nextInt(); // if there is another number  
         number1 = 0; // nothing added in the input

  • @danelyoung The scenario is still not working in pre-release, but works in the stable version.

Log in to reply