How to generate JAXB annotations from XML

73 views Asked by At

I need to generate class schema with jaxb annotation from xml. The xml it has hundreds of lines and annotations can not be generated manually.

I use gradle implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'

I already did Marshall and unmarshal successfully with small xml which annotations I added manually, but when I try with a bigger xml where manual annotation is not feasible, then, the problem occurs. Any suggestion is welcome.

I have tried many solutions suggested, such xjc (which never works properly for me.) find below logs. This solution I took it from: How to run jaxb xjc task with gradle? but not working for me. AS well I tried with Jakarta but not clear how to use or it seems its only available in IntelliJ ultimate, and currently we are limited to use community. I tried a online solution such https://easycodeforall.com/xml-to-pojo-converter.html but no luck, it generates but not with correct annotations. Does anyone has any clear solution steps in how to generate them? This is driving me more than crazy.

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.For more details on the daemon, please refer to https://docs.gradle.org/8.4/userguide/gradle_daemon.html
 in the Gradle documentation.
Process command line: C:\Program Files\Java\jdk-11\bin\java.exe --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED 
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED
 --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOf
MemoryError -Xms256m -Xmx512m -Dfile.encoding=windows-1252 -Duser.country=GB -Duser.language=en -Duser.variant -cp C:\Users\Richard Flores\Documents\SIT
A\Gradle\gradle-8.4-all\gradle-8.4\lib\gradle-launcher-8.4.jar -javaagent: C:\Gradle\gradle-8.4-all\gradle-8.4\lib\ag
ents\gradle-instrumentation-agent-8.4.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.4
Please read the following process output to find out more:
-----------------------

FAILURE: Build failed with an exception.
0

There are 0 answers