jaxb

JAXB Unable To Handle Attribute with Colon (:) in name?

I am attempting to use JAXB to unmarshall an XML files whose schema is defined by a DTD (ugh!). The external provider of the DTD has specified one of the element attributes as xml:lang: <!ATTLIST langSet id ID #IMPLIED xml:lang CDATA #REQUIRED > This comes into the xjc-generated class (standard generation; no *.xjb magic) as: @XmlAt...

Hyperjaxb and Apache CXF

Hey guys, I'm trying to use Hyperjaxb3 with Apache CXF to generate persistence annotations from a WSDL-first web service. I've plugged the Hyperjaxb3-ejb-plugin into the cxf-codegen-plugin, like so. <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <depende...

JAXB boolean handling oddities and JSF

There is a known bug in JAXB: https://jaxb.dev.java.net/issues/show_bug.cgi?id=733 JAXB does not properly generate boolean field getters and setters, this bug is left unfixed for backwards compatibility. A JAXB plugin exists and will ensure that the following getters and setters for boolean fields are generated: setXXX(Boolean value...

Dozer deep mapping not working

I am trying to use dozer 4.1 to map between classes. I have a source class that looks like this: public class initRequest{ protected String id; protected String[] details } I have a destination class that looks like this: public class initResponse{ protected String id; protected DetailsObject detObj; } p...

how to generate JMX MXBean compatible java class model from JAXB?

From the JMX MXBean specification, a java class type J must satisfy Either if J has at least one public constructor with a ConstructorProperties annotation, Or if J has a public no-arg constructor, and for every getter in J with type T and name N there is a corresponding setter with the same name and type So how can I use JAXB to gen...

JAXB marshals XML differently to OutputStream vs. StringWriter

I apologize if this has been answered, but the search terms I have been using (i.e. JAXB @XmlAttribute condensed or JAXB XML marshal to String different results) aren't coming up with anything. I am using JAXB to un/marshal objects annotated with @XmlElement and @XmlAttribute annotations. I have a formatter class which provides two meth...

Explanation of JAXB error: Invalid byte 1 of 1-byte UTF-8 sequence

We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315) What exactly does this mean and how can we resolve this?? We are executing the code as: ...

How to return an ArrayList from a database query?

I am querying a database for a web service using the Jersey JAX-RS. I can return a single row as XML or JSON, but I can't figure out how to return multiple records. Do I use an ArrayList? If so how? Does anyone have an example of how to do this? Thanks ...

Generating Java Objects with Ant (&xjc) - java packages

I am generating multiple XSD schemas into java objects, and i need to specify the root package. but the package attribute is not recognized by Ant... (don't know why...) what should i do? thanks! ...

WS Libs: com.sun.xml vs javax.xml

There are identical classes of java WebServices API & IMPL in those packages groups, only package names are different. http://mvnrepository.com/artifact/javax.xml http://mvnrepository.com/artifact/com.sun.xml Which ones should I use in my code? I would prefer NON-com.sun.* as per java conventions, but still my dependencies ( e.g. Spr...

jaxb: How can I bind nested element

There is my xml: <parent> <children> <child>1</child> <child>2</child> </children> </parent> I want to have the following Parent class: @XmlRootElement Parent{ @XmlElement(name="children/child") List<Child> children; } I don't want to have class for element 'children'. How should I map field children ? ...

JAXB code generation: restricted type -> how to remove a zero occurrence field?

Hi all, I use JAXB 2.1 to generate Java classes from several XSD files that I cannot modify (coming from a WSDL file actually), and I have a problem related to complex type restriction. On of the restrictions modifies the occurence configuration from minOccurs="0" maxOccurs="unbounded" to minOccurs="0" maxOccurs="0". Thus this field is ...

Jersey / JAXB: Unmarshaling of empty json array results in a list with one item where all fields are set to null

I have a really simple rest web service returning a list of questions. This code works as expected when the number of questions returned are greater than zero. But if the server returns an empty json array like [], JAXB creates a list with one question instance where all fields are set to null! I'm new to both Jersey and JAXB so I don'...

Jaxb system path

Hi, I just installed java Web Service Developer Pack 2.0 to use JAXB for xml operations. The tutorial says me add "C:\Sun\jwsdp-2.0\jaxb\bin" to the system path.I select Computer->Properties->Advanced System Settings. I come to the Advanced tab I open the window Environment variables. and i selected PATH from user variables,selected ed...

How do I add array indices to the XML produced by JAXB?

I have a Java bean ala @XmlRootElement public class Bean { @XmlElementWrapper(name = "ints") @XmlElement(name = "int") int[] values; // constructors, getters, setters, etc... } JAXB is producing XML like <bean> <ints> <int>12</int> <int>34</int> <int>56</int> </ints> </bean> I would like...

Trimmed down JAXB for just unmarshalling?

I'm building an application where space is at a premium. I'd really like to use JAXB's unmarshalling capabilities, but including the whole library is out of the question. Has anyone pared it down so that only the bits needed for unmarshalling are included? ...

Maven Release Plugin with JAXB issues

Hiya, We've got a project set up to use the Maven Release Plugin which includes a phase that unpacks a JAR of XML schemas pulled from Artifactory and a phase that generates XJC classes. We're on maven release 2.2.1. Unfortunately the latter phase is executing before the former which means that it isn't generating the XJC classes for th...

JAXB Mapping cyclic references to XML

I have an object graph that contains a cycle. How do I get JAXB to handle this? I tried using the @XmlTransient annotation in the child class but the JAXB marshaller still detects the cycle. @Entity @XmlRootElement public class Contact { @Id private Long contactId; @OneToMany(mappedBy = "contact") private List<Contac...

Marshalling empty list - jaxb

I have the following code int testInt = 2; String stringArg = "test"; List<Activity> activityList = new ArrayList<Activity>(); //activityList.add(new Activity(testInt, testInt, testInt, null, null, null, stringArg, stringArg)); //activityList.add(new Activity(testInt, testInt, testInt, null, null, null, stringArg, stringArg)); Activiti...

which jaxb plugin to use?

I found two jaxb maven plugins: 1. <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> 2. <groupId>com.sun.tools.xjc.maven2</groupId> <artifactId>maven-jaxb-plugin</artifactId> What is difference in these two plugins? ...