jaxb

Element Defaulting using JAXB

HI All, I am trying to use JAXB 1.0 provided by JDeveloper 10g version. I have created a Schema definition with elements having default values. I have following questions: Whenever I create the Java Content tree using the JAXB generated classes, the java objects should have been created with the default values mentioned in the XML sch...

Java JAXB Pros/Cons and Documentation

It's been a while since I used Java in anger so please forgive me if this is silly. I have just got started on a Java project where we are using JAXB to de-serializing an incoming XML string (from Jetty Server). The project is only using JAXB for this situation. What are the alternatives to JAXB? What are pros/cons of JAXB to these alt...

Intermittent ClassCastException from ElementNSImpl to own type during unmarshalling

We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions sometimes when trying to iterate over a list of unmarshalled objects. The important bit is sometimes, after a reboot the particular code works fine. This seems to point in the direction of concurrency/timing/race condition. I can confirm t...

How do I ensure Schema Extensibility using JAXB

If I am using JAXB as part of Metro Web Services under Glassfish v2, how do tell JAXB to add: <xsd:any/> and <xsd:anyAttribute/> tags to my generated complex types so that if I make changes in the future to add elements or attributes to my response objects then my current clients won't break. JAXB documentation seems somewhat lacki...

JAXB XmlID and XmlIDREF annotations (Schema to Java)

I am exposing a web service using CXF. I am using the @XmlID and @XmlIDREF JAXB annotations to maintain referential integrity of my object graph during marshalling/unmarshalling. The WSDL rightly contains elements with the xs:id and xs:idref attributes to represent this. On the server side, everything works really nicely. Instances of ...

Java 6 and JaxB 2.1

The original release of Java 6 came with JAXB 2, but I have been told that 'later' Java 6 releases ship with JAXB 2.1. Does anyone know what the first version of Java 6 to ship with JAXB 2.1 was? ...

JAXB Documentation Annotation

I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name="ClientData") public class ClientData { /** * The first address field of the person */ private String address1 = null; } which produces this xml fragment when i generate the xsd schema <xs:complexType name="clientData"> <xs:sequence> ...

Creating a custom JAXB annotation

Do people have any recommendations on how i could write my own custom JAXB annotation handling class to support the generation of xs:annotation/xs:documentation elements in the xsd schema?. I'd like to create a new java annotation "@XmlAnnotation" which would include a "documentation" attribute. I'd then make these classes available to t...

How to intercept xml response and request during web service invocation?

I wonder if there is some neat way to intercept xml request send during java webservice method invocation and xml given in response? I don't want to print those xmls to standard output but to "catch" them in some string. ...

Mapping CSV to a Model

I am writing a simple CSV to XML processor in Java. I am using JAXB to generate a model in java from a DTD. I need to process the CSV format into this model, and then marshall it into the XML that complies to the DTD. I am using JAXB to marhall the data from the Java model to the XML. I have to write the CSV-Model mapping myself. At th...

Custom serialization in JAXB

Hi, Is there a way to customize XML serialization in JAXB, in the same way that it's possible using IXmlSerializable in .NET? (i.e. the ability to directly control serialization of an object using the equivalent of an XmlReader/Writer). I've taken a look at XmlAdapter and @XmlJavaTypeAdapter, but they just seem to be used to transform ...

converting RELAX NG to XSD with trang while keeping external namespace elements (for use with JAXB)

I am using trang to convert a RELAX NG .rng file to an XML Schema .xsd file for use with JAXB. Is there a way to put attributes/elements in the .rng file and have them show up in the .xsd file? I have an external .xjb file that I use for JAXB settings, but there are some JAXB settings that are very closely coupled to the schema itself a...

Java's default JAXB implementation is chosen over my classpath.

I've written a java application that utilizes JAXB for XSL transforms. I've included the saxon9.jar in my classpath so that I can use XSLT 2.0 rather than XSLT 1.0 on the command line. java -classpath ./lib/saxon9.jar:./ -jar myApp.jar I've included code in my XSL to report the XSLT used. <xsl:comment><xsl:text > </xsl:text>XSLT Ver...

JAXB: Anonymous simple types as enums?

When generating Java from an XSD via the XJC compiler, I always get the type java.langString for elements with anonymous simpleTypes like this: <xsd:element name="Product"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Product1"/> <xsd:enumeration value="Product2"/> <xsd:enumeration value="...

How to instantiate an empty element with JAXB

I use JAXB to create XML messages. The XML I need to create is (for the sake of simplicity): <request> <header/> </request> My code looks like this: import javax.xml.bind.annotation.*; @XmlRootElement(name = "request") public class Request { private String header; @XmlElement(required=true) public String getHeader() ...

JAXB XML output format questions

Hi, I have Java classes with the following structure (the class names do not imply anything, I was just making them up). package test; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.annotation.XmlAccessTy...

What is JAXB and why would I use it?

There is guy here swearing up and down that JAXB is the greatest thing since sliced bread. I am curious to see what stackoverflow users think the use case is for JAXB and what makes it a good or a bad solution for that case. ...

JAXB inheritance, unmarshal to subclass of marshaled class

I'm using JAXB to read and write XML. What I want is to use a base JAXB class for marshalling and an inherited JAXB class for unmarshalling. This is to allow a sender Java application to send XML to another receiver Java application. The sender and receiver will share a common JAXB library. I want the receiver to unmarshall the XML into ...

Eclipse RCP case study, please help to solve!

I am interested to learn about Eclipse RCP, I have got some basic knowledge, but I wanted to know more what it is capable of. So I encouraged my self to create a set of requirements, analyze them, and come up with design decisions about how they can be met using Eclipse RCP as the base framework, and eventually implement them with Eclip...

JAXB gives me: java.lang.IllegalArgumentException: is parameter must not be null

I am doing using JAXB to unmarshall some XML into Java objects: My code looks a little like this: InputStream testMsg = getClass().getResourceAsStream("TestDocumentEvent.xml"); Unmarshaller unmarshaller = JAXBContext.newInstance(DocumentEvent.class).createUnmarshaller(); DocumentEvent unmarshalled = (DocumentEvent) unmarshaller.unmarsh...