# Been getting an error trying to render a basic tilemap in slick2d

**URL:** <https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415>\
**Category:** Questions\
**Created:** [March 23, 2015, 7:12pm UTC](https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415 "2015-03-23T19:12:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newell](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@newell](https://discourse.mapeditor.org/u/newell)\
**Post date:** [March 23, 2015, 7:12pm UTC](https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415/1 "2015-03-23T19:12:54Z")

</div>

```auto
java.lang.NullPointerException
	at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:139)
	at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:661)
	at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:106)
	at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:90)
	at game.Game.init(Game.java:20)
	at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
	at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
	at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
	at game.Main.main(Main.java:26)
Mon Mar 23 14:56:44 EDT 2015 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
	at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:695)
	at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:106)
	at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:90)
	at game.Game.init(Game.java:20)
	at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
	at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
	at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
	at game.Main.main(Main.java:26)
Caused by: java.lang.NullPointerException
	at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:139)
	at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:661)
	... 7 more

```

does anyone know why ive been getting this error  
im just trying to render my tilemap in a basic statebasedgame

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [March 23, 2015, 8:42pm UTC](https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415/2 "2015-03-23T20:42:18Z")

</div>

That looks like a bug in Slick2D. Here’s the snippet of code it’s choking on:

```java
for (int i = 0; i < pElements.getLength(); i++) {
    Element tileElement = (Element) pElements.item(i);

    int id = Integer.parseInt(tileElement.getAttribute("id"));
    id += firstGID;
    Properties tileProps = new Properties();

    Element propsElement = (Element) tileElement.getElementsByTagName(
            "properties").item(0);
    NodeList properties = propsElement.getElementsByTagName("property"); // line 139
    for (int p = 0; p < properties.getLength(); p++) {
        Element propElement = (Element) properties.item(p);

        String name = propElement.getAttribute("name");
        String value = propElement.getAttribute("value");

        tileProps.setProperty(name, value);
    }

    props.put(new Integer(id), tileProps);
}

```

Here, it’s going through all the `<tile>` elements in a `<tileset>`, and the error it makes is that it assumes that a `<tile>` element always has a child `<properties>` element. There isn’t one, so it runs into a null pointer exception.

This has always been a wrong assumption, though until recently it will have mostly worked fine. Now, Tiled has other reasons to write out a `<tile>` element than it having properties (like maybe it has terrain information or maybe it has its own image reference).

So, apart from the bug, Slick2D also does not yet support for example image collection tilesets added with Tiled 0.10. You’ll want to talk to the Slick2D developers about fixing it and possibly adding support for newer Tiled features.

---

<div class="post-metadata">

**Author:** ![newell](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@newell](https://discourse.mapeditor.org/u/newell)\
**Post date:** [March 23, 2015, 9:37pm UTC](https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415/3 "2015-03-23T21:37:14Z")

</div>

I do appreciate the help. To clarify, your saying tiled doesn’t really work with slick2d anymore ,or did I create the map incorrectly? I heard slick2d stopped development but it is open source correct me if im wrong because im unsure. How would i go about fixing the problem. I’d have to give my tiles properties?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [March 23, 2015, 9:48pm UTC](https://discourse.mapeditor.org/t/been-getting-an-error-trying-to-render-a-basic-tilemap-in-slick2d/415/4 "2015-03-23T21:48:40Z")

</div>

Right, if you’re familiar with Java it should be trivial for you to fix this bug in Slick2D and keep going. However, depending on what feature you’re using you will either have to add it to Slick2D or stop relying on it.

My guess is that you’ve created an “image collection” tileset in Tiled, and unless you modify Slick2D to support this it will not be able to render your map correctly.
