How to generate JAXB classes from XSD?

XJC is included in the bin directory in the JDK starting with Java SE 6. For an example see: http://blog.bdoughan.com/2010/09/processing-atom-feeds-with-jaxb.html The contents of the blog are the following: Processing Atom Feeds with JAXB Atom is an XML format for representing web feeds. A standard format allows reader applications to display feeds from different sources. In … Read more

Difference of Maven JAXB plugins

Let’s summarize. We have/had: the maven-jaxb2-plugin (https://github.com/highsource/maven-jaxb2-plugin) the maven-jaxb-plugin (https://jaxb.dev.java.net/jaxb-maven2-plugin/) the jaxb2-maven-plugin (https://github.com/mojohaus/jaxb2-maven-plugin) Based on the comments of this thread, I’ve always used the maven-jaxb2-plugin (i.e. plugin #1): Concerning the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin versus com.sun.tools.xjc.maven2:maven-jaxb-plugin, from my point of view it’s definitely the first one (http://maven-jaxb2-plugin.java.net/). This plugin has much more features than com.sun.tools.xjc.maven2:maven-jaxb-plugin, the development is … Read more

How do I instantiate a JAXBElement object?

When you imported the WSDL, you should have an ObjectFactory class which should have bunch of methods for creating various input parameters. ObjectFactory factory = new ObjectFactory(); JAXBElement<String> createMessageDescription = factory.createMessageDescription(“description”); message.setDescription(createMessageDescription);

JAXB creating context and marshallers cost

Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group. JAXBContext is thread safe and should only be created once and reused to avoid the cost of initializing the metadata multiple times. Marshaller and Unmarshaller are not thread safe, but are lightweight to create and could be created … Read more

Use JAXB to create Object from XML String

To pass XML content, you need to wrap the content in a Reader, and unmarshal that instead: JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(“xml string here”); Person person = (Person) unmarshaller.unmarshal(reader);

No @XmlRootElement generated by JAXB

To tie together what others have already stated or hinted at, the rules by which JAXB XJC decides whether or not to put the @XmlRootElement annotation on a generated class are non trivial (see this article). @XmlRootElement exists because the JAXB runtime requires certain information in order to marshal/unmarshal a given object, specifically the XML … Read more

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

The JAXB APIs are considered to be Java EE APIs and therefore are no longer contained on the default classpath in Java SE 9. In Java 11, they are completely removed from the JDK. Java 9 introduces the concepts of modules, and by default, the java.se aggregate module is available on the classpath (or rather, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)