Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtiled-java NullPointerException #2052

Closed
carif opened this issue Jan 3, 2019 · 7 comments
Closed

libtiled-java NullPointerException #2052

carif opened this issue Jan 3, 2019 · 7 comments
Labels
bug Broken behavior.

Comments

@carif
Copy link

carif commented Jan 3, 2019

Libtiled crashes with the following exception:

java.lang.NullPointerException
	at tiled.io.TMXMapReader.unmarshalTileset(TMXMapReader.java:367)
	at tiled.io.TMXMapReader.buildMap(TMXMapReader.java:807)
	at tiled.io.TMXMapReader.unmarshal(TMXMapReader.java:848)
	at tiled.io.TMXMapReader.readMap(TMXMapReader.java:876)
	at theengine.fileio.LevelLoader.loadLevel(LevelLoader.java:26)
	at theengine.fileio.LevelLoader.loadLevel(LevelLoader.java:15)
// the line which starts loading the level
LevelLoader.loadLevel("C:/Program Files/Tiled/examples/orthogonal-outside.tmx");
// the following path also crashes: C:\\Program Files\\Tiled\\examples\\orthogonal-outside.tmx

    public static Level loadLevel(String path) {
        return LevelLoader.loadLevel(Paths.get(path));
    }
    
    public static Level loadLevel(Path path) {
        TMXMapReader reader = new TMXMapReader();
        if(!reader.accept(path.toFile())) return null;
        
        System.out.println(path.toAbsolutePath().toString());
        
        Map map = null;
        try {
            map = reader.readMap(path.toAbsolutePath().toString());
        } catch (Exception e) {
            // Exception is thrown here!!!
            e.printStackTrace();
        }

Using:
Windows 10 64bit; 1803
Java 10 x64 (see #2048 as to why not Java 11) with Gradle 4.10.2
libtiled-java: 0.17
javax.xml.bind:jaxb-api:2.3.0
Eclipse 2018-09 (4.9.0)

Trying to use the version from Github instead also failed as I was not able due to missing classes (MapData for example).

@Ansury
Copy link

Ansury commented Jan 28, 2019

Just ran into the missing MapData class myself. File get deleted accidentally or something?

@Ansury
Copy link

Ansury commented Jan 28, 2019

Hmm. Found this commit from 6/20/2017 where a number of these files (MapData + others) suddenly appeared in code, but no *Data classes:
Refactor package names to org.mapeditor, create model from xsd and update version numbers to 1.0.1

Guessing these *Data classes need to be generated somehow...

@mikepthomas
Copy link
Contributor

mikepthomas commented Mar 16, 2019

Hi @Ansury, Yes the files are generated from an XML schema during the build, I have just pushed a commit to one of my previous pull requests to support building with JDK versions 9 and above:
#1925

I have also recently pushed a new version to Maven Central (https://search.maven.org/artifact/org.mapeditor/libtiled/1.0.2/jar) try that and let me know if that fixes the issue :)

@bjorn bjorn added the bug Broken behavior. label Mar 17, 2019
@bjorn
Copy link
Member

bjorn commented May 16, 2019

@Ansury Did you ever try the new version pushed by @mikepthomas, to see if this issue still exists?

@bjorn
Copy link
Member

bjorn commented Jan 30, 2020

Whoops, maybe I asked the wrong person.

@MinecraftPlaye, did you ever try the 1.0.2 version of libtiled, to see if this issue still exists?

@carif
Copy link
Author

carif commented Feb 3, 2020

Whoops, maybe I asked the wrong person.

@MinecraftPlaye, did you ever try the 1.0.2 version of libtiled, to see if this issue still exists?

Ah, thx for the reminder. I kind of forgot about this issue. I just tested it out by setting up a new minimal test project and ran into #2048 (my comment there).

@carif
Copy link
Author

carif commented Mar 1, 2020

Version 1.2.3 from Maven Central resolves this problem.

@carif carif closed this as completed Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

4 participants