jaxb2

getting error only one globalBindings customization is allowed in a whole compilation while using maven-jaxb2-plugin

∥☆過路亽.° 提交于 2021-02-08 03:33:48
问题 I am using maven-jaxb2-plugin. Here is my plugin configuration <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <executions> <execution> <id>xjc-serviceoperations</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <generateDirectory>${basedir}/src/main/java/</generateDirectory> <schemaDirectory>src/main/resources/schemas/lmsapi/serviceoperations</schemaDirectory> <removeOldOutput>false</removeOldOutput> <

CannotResolveClassException while trying to transform xml string into java object

旧时模样 提交于 2021-01-28 07:45:37
问题 I am trying to develop a mule flow which takes a xml in the form of a string from a JMS queue and converts it into a POJO. I am using JAXB annotations to define the mappings between the xml and the class attributes. Below is the sample xml that is received on the JMS queue as a string. <FCUBS_NOTIFICATION xmlns="http://fcubs.ofss.com/notify/NOTIF_UP_TRANSACTION"> <FCUBS_NOTIF_HEADER> <MSGID>9132820000357947</MSGID> </FCUBS_NOTIF_HEADER> </FCUBS_NOTIFICATION> My POJO class is as below: package

JAXB remove XmlRootElement wrapper

淺唱寂寞╮ 提交于 2020-06-24 12:38:00
问题 I have this @XmlRootElement class Person. @XmlRootElement class Person { private String desc; } and the return content is {"Person": {"desc": "abc"} } and I really don't want the root wrapper, so I want the content to looks like {"desc": "abc"} Can I accomplish this via JaxB? If so, how? Thanks! 回答1: JAXB is an API for XML, not JSON. However, there are some JSON libraries (at least Jackson) which can utilize JAXB annotations. I don't know which one you are using, so I don't know exactly how

Validate xml created using jaxb against an xsd file

半城伤御伤魂 提交于 2020-01-21 01:44:37
问题 I have a xml file created using jaxb. I need to validate it against a xsd document. Is it possible to just do validation without unmarshalling. I need to then print the errors in the xml file. 回答1: Yes you can use validator found in java from 1.5. here is the reference doc Apart from it you can use dom based or stream based API to validate your XML document against xsd file. If you wish to use SAX API for your task then hear is the example: try { String schemaLang = "http://www.w3.org/2001

Validate xml created using jaxb against an xsd file

风流意气都作罢 提交于 2020-01-21 01:44:06
问题 I have a xml file created using jaxb. I need to validate it against a xsd document. Is it possible to just do validation without unmarshalling. I need to then print the errors in the xml file. 回答1: Yes you can use validator found in java from 1.5. here is the reference doc Apart from it you can use dom based or stream based API to validate your XML document against xsd file. If you wish to use SAX API for your task then hear is the example: try { String schemaLang = "http://www.w3.org/2001

JAXB unmarshalling not tolerating whitespace around token enumerations

青春壹個敷衍的年華 提交于 2020-01-15 09:13:51
问题 JAXB 2 (Oracle / Metro version 2.2.7 and I suspect others as well) doesn't seem to tolerate whitespace around values in enumeration elements. Minimal example follows. Both xmllint and Xerces validate the instance against the schema. The puzzling think is that JAXB validation doesn't complain but returns null when trying to access the value. How can I configure it to return the value properly? update: I 've tried associating an XmlAdapter to trim the strings, as suggested here, but the result

JAXB unmarshalling not tolerating whitespace around token enumerations

那年仲夏 提交于 2020-01-15 09:13:00
问题 JAXB 2 (Oracle / Metro version 2.2.7 and I suspect others as well) doesn't seem to tolerate whitespace around values in enumeration elements. Minimal example follows. Both xmllint and Xerces validate the instance against the schema. The puzzling think is that JAXB validation doesn't complain but returns null when trying to access the value. How can I configure it to return the value properly? update: I 've tried associating an XmlAdapter to trim the strings, as suggested here, but the result

Line number of individual XML element while unmarshalling using jaxb

笑着哭i 提交于 2020-01-15 07:51:26
问题 I have a class Person with attributes name and address. I display it in a XML. While unmarshalling from XML will it be possible to get line number for name and address separately. I tried using Locator. But it does not provide individual line numbers. 回答1: The EclipseLink JAXB (MOXy) and the JAXB reference implementation each have their own @XmlLocation annotations for supporting this use case. This allows you to store the location on the XML element corresponding to the object as an instance

Moxy not honoring the super class/interface properties

跟風遠走 提交于 2020-01-14 14:12:28
问题 enter code here I have the properties for a Customer spread across two interfaces as shown below. I have the external xml binding defined using the sub interface ICustomer. When I marshall the pojo to xml, it seems like the Moxy is ignoring the super interface's property firstName . Is this a bug or do I need to explicitly specify each of these two interfaces in the xml meta-data? Base interface public interface IBaseCustomer { String getFirstName(); void setFirstName(final String firstName);

Moxy not honoring the super class/interface properties

徘徊边缘 提交于 2020-01-14 14:09:22
问题 enter code here I have the properties for a Customer spread across two interfaces as shown below. I have the external xml binding defined using the sub interface ICustomer. When I marshall the pojo to xml, it seems like the Moxy is ignoring the super interface's property firstName . Is this a bug or do I need to explicitly specify each of these two interfaces in the xml meta-data? Base interface public interface IBaseCustomer { String getFirstName(); void setFirstName(final String firstName);