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

Error with libtiled in Java 21: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException #3919

Open
ajh123 opened this issue Mar 23, 2024 · 1 comment
Labels
bug Broken behavior.

Comments

@ajh123
Copy link

ajh123 commented Mar 23, 2024

Describe the bug

When I create an instance of org.mapeditor.io.MapReader the following error is produced: Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

To Reproduce
Steps to reproduce the behavior:
1.
Import libtiled into your Java project, for example the following Gradle:

plugins {
    id 'java'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 21
targetCompatibility = 21

dependencies {
    testImplementation platform('org.junit:junit-bom:5.9.1')
    testImplementation 'org.junit.jupiter:junit-jupiter'
    implementation 'org.mapeditor:libtiled:1.4.2'
}

test {
    useJUnitPlatform()
}

Somewhere in your code create an instance of MapReader, for example:

import org.mapeditor.io.MapReader;

public class App {
    public static void main(String[] args) {
        MapReader reader = new MapReader();
    }
}
  1. Run the program
  2. See error

Expected behavior
A clear and concise description of what you expected to happen.

I expect an instance of MapReader to be created without any errors.

Media
If applicable, add screenshots or videos to help explain your problem.

N/A

Specifications:

  • OS: [e.g. Windows 10]: Windows 10: (I don't think this matters because the issue comes from Java it self).
  • Tiled Version: [e.g. 1.0.0. You can get this from Help -> About Tiled]: 1.10.2 (I don't think this actually matters with this).

Java version

> java --version
openjdk 21.0.2 2024-01-16 LTS
IBM Semeru Runtime Open Edition 21.0.2.0 (build 21.0.2+13-LTS)
Eclipse OpenJ9 VM 21.0.2.0 (build openj9-0.43.0, JRE 21 Windows 10 amd64-64-Bit Compressed References 20240116_95 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 78c4500a434 based on jdk-21.0.2+13)

Semi-related issues
#3284 https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception

Until a proper solution is made, I would like to know if there are any workarounds available.

@ajh123 ajh123 added the bug Broken behavior. label Mar 23, 2024
@ajh123
Copy link
Author

ajh123 commented Mar 23, 2024

As a better alternative, I've now switched my project to use LibGDX, which has built in Tiled support. However, I will let you decided whether or not this should remain open.

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

1 participant