简体   繁体   中英

Generating jaxb classes from a schema

I am trying to use the Jaxb classes generator in eclipse to generate jaxb classes from my schema. I receive the following error:

"The classpath for this project does not appear to contain the necessary libraries to proceed with class generation. Please insure that a JAXB implementation is available on the classpath."

How can i solve this problem?

After a lot of research here is what I have done to fix the issue. Windows> Preferences> Java> InstalledJREs...make sure to point your jre to the jdk directory. I was pointing to JRE and as soon as I changed it to JDK, it started working. Hope this will help you guys.

Make sure to include the jaxb-impl.jar library in your project. You can download one for example from here: https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.4/jaxb-impl-2.2.4.jar

If you're using Maven, you can include this as a dependency, otherwise download the file and add it as a library in your project.

If you need a different version of the library, move up one directory in the link that I added above, you can find other versions there as well.

If you want to automate the class generation, since you're changing the schema on a regular basis, you should automate the process, eg through Maven.

Windows> Preferences> Java> InstalledJREs > Execution Environment. Select an environment JDK 1.8 and then try to create JAXB Classes.

Click on Below Image Link For Details.

Select the execution Environment

Put the tools.jar in the classpath of the projecct (where the generated code will reside).

I found an explanation here https://bugs.eclipse.org/bugs/show_bug.cgi?id=345617 It does not work because Eclipse only puts the JRE libraries in the classpath of the project. Since the xjc code is in tools.jar you need to provide this extra step.

Download com.springsource.com.sun.tools.xjc-2.1.7.jar

and configure the build path. This solved the warning and the error for me. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM