dbptk-developer icon indicating copy to clipboard operation
dbptk-developer copied to clipboard

dbptk-app-2.10.1.jar: javax.xml.bind.JAXBException with Java 15

Open ibbenz opened this issue 2 years ago • 2 comments

After starting up the dbptk-app the following errors occurred:

Errors: WARN could not get type for name javax.xml.bind.annotation.adapters.XmlAdapter from any class loader Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

This issue seems to origin from an incompatibility with Java 15. I use OpenJDK Runtime Environment (build 15.0.2+10) from BellSoft.

According to the following link the jaxb-api jar has to be integrated in the application: https://www.studytonight.com/post/solved-javalangnoclassdeffounderror-javaxxmlbindjaxbexception-in-java-11

Question Will there be soon a release which will tackle this issue? Which would be a feasible workaround where the dbptk-app is able to run with Java 15?

ibbenz avatar Sep 23 '22 07:09 ibbenz

You can add the additional jaxb-api jar into the classpath as you would do to add additional JBDC drivers. https://github.com/keeps/dbptk-developer/wiki/How-to-use-a-JDBC-driver-in-DBPTK-Developer

luis100 avatar Sep 23 '22 08:09 luis100

Thank you, the validation seems to work:

java -cp "C:\KOST\Software_KOST\dbptk_Developer\dbptk-app-2.10.1.jar;C:\KOST\Software_KOST\dbptk_Developer\jaxb-api-2.3.1.jar" com.databasepreservation.Main validate -if C:\KOST\SIARD_TESTS\2022_07_11_SIARD_Test_MySQL\0_Testdatei\0_4-6_oe_Northwind_complex.siard

ibbenz avatar Sep 26 '22 07:09 ibbenz

This error is still present for dbptk-2.10.3.jar luis's fix does not fix.

C:\Users\SH1U\Downloads>java "-Dfile.encoding=UTF-8" -cp "c:\users\sh1u\downloads\dbptk-app-2.10.3.jar;c:\users\sh1u\downloads\jaxb-api-2.4.0-b180830.0359.jar" com.databasepreservation.Main validate -import-file TestDB-with-slash.siard Validate SIARD at 'TestDB-with-slash.siard' Exception in thread "main" java.lang.IllegalAccessError: class com.databasepreservation.modules.siard.validate.component.tableData.RequirementsForTableDataValidator (in unnamed module @0x3b9d6699) cannot access class com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl (in module java.xml) because module java.xml does not export com.sun.org.apache.xerces.internal.jaxp to unnamed module @0x3b9d6699 at com.databasepreservation.modules.siard.validate.component.tableData.RequirementsForTableDataValidator.(RequirementsForTableDataValidator.java:145) at com.databasepreservation.modules.siard.validate.component.factories.RequirementsForTableDataComponentFactory.buildComponent(RequirementsForTableDataComponentFactory.java:55) at com.databasepreservation.modules.siard.validate.SIARDValidateModule.getValidationComponents(SIARDValidateModule.java:205) at com.databasepreservation.modules.siard.validate.SIARDValidateModule.validate(SIARDValidateModule.java:118) at com.databasepreservation.SIARDValidation.validate(SIARDValidation.java:92) at com.databasepreservation.Main.runValidation(Main.java:191) at com.databasepreservation.Main.internalMain(Main.java:129) at com.databasepreservation.Main.main(Main.java:81)

C:\Users\SH1U\Downloads>java -version openjdk version "17.0.5" 2022-10-18 LTS OpenJDK Runtime Environment Corretto-17.0.5.8.1 (build 17.0.5+8-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.5.8.1 (build 17.0.5+8-LTS, mixed mode, sharing)

stighemmer avatar Jan 04 '23 10:01 stighemmer

Try this one:

wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar
java  --add-opens java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED -cp dbptk-app-2.10.3.jar:jaxb-api-2.3.1.jar com.databasepreservation.Main validate -if test.siard

We will try to improve Java 9+ compatibility in the next release.

luis100 avatar Jan 04 '23 11:01 luis100

That worked! Thank you. On Windows the command line ended up as: java "-Dfile.encoding=UTF-8" --add-opens java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED -cp "dbptk-app-2.10.3.jar;jaxb-api-2.3.1.jar" com.databasepreservation.Main validate -if TestDB-with-slash.siard

stighemmer avatar Jan 04 '23 11:01 stighemmer