2

I'm writing a Java program that uses JAXB to create XML files from a given XSD and am using Eclipse for the first time. I have also downloaded EclipseLink to use within Eclipse as I want to use MOXy as my JAXB provider. Unfortunately, I'm not sure if I'm using it correctly. I've read various documentation, blogs and forums which mentions various techniques but as I'm new to it, I'm not sure if my understanding is correct. Can someone enlighten me please?

I understand that MOXy is an alternative JAXB implementation to the Reference Implementation and as such has features that could be useful above those found in the Reference Implementation. With this in mind, I downloaded EclipseLink and placed the eclipselink.jar in my classpath and added the jaxb.properties file in my package. Under the eclipselink\jlib folder there is another folder called moxy that contains 6 jar files, what are these for and do I also need to include them in my classpath?

The generated JAXB classes from Eclipse have automatically generated comments at the top of the files. These comments mention that they were generated by the Reference Implementation and not MOXy. Should I expect the JAXB classes to be generated by MOXy and not the JAXB Reference Implementation?

Thx

bdoughan
  • 147,609
  • 23
  • 300
  • 400
user3572079
  • 135
  • 1
  • 2
  • 12
  • Assuming you did `right click on xsd > Generate > AJXB classes...` Did you tick the checkbox `use EclipseLink MOXy as the JAXB implementation` ? – A4L Oct 28 '14 at 13:47
  • I created my Project under New > Other.. > JAXB > JAXB Project and didn't see "use EclipseLink MOXy as the JAXB implementation" when generating the JAXB classes. – user3572079 Oct 29 '14 at 09:58

1 Answers1

1

I understand that Moxy is an alternative JAXB implementation to the Reference Implementation and as such has features that could be useful above those found in the Reference Implementation.

MOXy and the JAXB reference implementation (RI) are both implementations of JSR-222, and pass the same compliance test suites. Anywhere the RI is used MOXy could be used instead without impacting any users. For example WebLogic now uses MOXy as the default JAXB provider and you can configure it to use the RI as an alternate provider.

Under the eclipselink\jlib folder there is another folder called moxy that contains 6 jar files, what are these for and do I also need to include them in my classpath?

The jlib/moxy folder contains the implementation of XJC which is called from our bin/jaxb-compiler.sh script as well as some supported libraries for those people using versions of Java prior to Java SE 6.

The generated JAXB classes from Eclipse have automatically generated comments at the top of the files. These comments mention that they were generated by the Reference Implementation and not Moxy. Should I expect the JAXB classes to be generated by Moxy and not the JAXB Reference Implementation?

MOXy leverages the XJC (XML Schema to Java Compiler) from the JAXB reference implementation. This is why you see the comments in the generated comments. XJC is a very nice component with a lot of useful community contributed extensions, so we didn't invent our own.

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Thanks, Blaise. To generate the JAXB classes, I chose my "Target runtime" as jdk160_24 rather than jre6 when setting up my JAXB Project as it has its own XJC. Since I generated my JAXB classes without putting eclipselink.jar or any of the jlib/moxy jars in my classpath at the time of JAXB class generation but subsequently placed eclipselink.jar in my classpath, and a jaxb.properties file in my package and still have no jlib/moxy jars, is my environment set up to use MOXy or do I still need the lib/moxy jars in my classpath and maybe re-generate my classes with all these jars in place? – user3572079 Oct 29 '14 at 09:39