jaxb

JAXB XJC code generation issue with xs: list date and dateTime type.

I am using an xsd having two <xs:list/> elements. <xs:element name="packorder1" type="DateTimeTypeXsList"/> <xs:element name="packorder2" type="DateTypeXsList"/> <xs:simpleType name="DateTimeTypeXsList"> <xs:list itemType="xs:dateTime"/> </xs:simpleType> <xs:simpleType name="DateTypeXsList"> <xs:list itemType="xs:date"/> </xs:si...

How to rename XML attributes from Java classes using JAXB annotations?

Hi, I have this class defintion: @XmlRootElement public class RssRoot { private String _version; private String _xmlns_content; @XmlAttribute() public String get_version() { return _version; } @XmlAttribute() public String get_xmlns_content() { return _xmlns_content; } public void set_version(String version) { _version = ...

Unmarshalling xml to a bean with a colleciton

I'm working with Redmine's xml rest api. The service returns xml like in the example below. I'm using the Jersey Client API to communicate with the restful service. Mapping the plain fields (id, name and so on) in project are no problem, but I'm having trouble with the trackers list. <project> <id>2</id> <name>Project X</name> ...

JAXB Marshalling and unmarshalling avoiding namespaces.

Hello All, this is a very common problem but I still need a specific solution if someone can please provide me with a solution. JAXB.unmarshal('file', class); However because of the namespaces present in the xml file the class object is not getting populated with the inner elements. The turnaround I found was to create a JAXBContext ...

Jersey client, JAXBContext used when application is executed with Maven, but not with java -jar

I'm implementing a rest client consuming json data using the Jersy Client API. I don't really have much experience with JAXB, and especially not in combination with JSON. I've followed the example provided here (http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with) and registered a JAXBContext. Everything w...

how java jaxb works?

Just curious about how jaxb works, I have a class annotated as follows: @XmlRootElement(name = "MyJaxb") Class MyJaxb { @XmlElement protected String str; public void setStr(String str) { this.str = str; } } The access modifier of field str is protected, why Jaxb can still marshall and unmarsh...

JAXB marshalling problem - probably namespace related

Given the intitial XML (BPEL) file: <?xml version="1.0" encoding="UTF-8"?> <process name="TestSVG2" xmlns="http://www.example.org" targetNamespace="http://www.example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <sequence> <receive name="Receive1" createInstance="yes"/> <assign name="Assign...

Is it possible to catch SAXParseException in JAX-RS/JAXB webservice?

I would like to check in a JAX-RS webservice request that valid XML was included in the body. However, this code: @PUT @Produces(MediaType.TEXT_XML) @Consumes(MediaType.TEXT_XML) @Path("/{objectID}") public MyObject updateMyObject(@PathParam("objectID") String existingObjectID, JAXBElement<MyObject> object) { MyObject udpatedObject...

What the difference between JAXB and CXF?

Hi, I have tried to generate java classes from a schema xsd with JAXB2.1 and run XJC and it works. I have included the schema in a wsdl file and i generate java classes with wsdl2java command using CXF. The problem is abouta java class where there are difference: The difference is the content attribute and its getter and setter which is...

JAXB unmarshal problem with XSD <choice> element

Hi, I'm experiencing a problem unmarshalling a element in an XML document using JAXB RI 2.2.1. The element is defined as follows (the full XSD is too large to post): <xsd:element name="PatternExpression" type="PatternExpression_Type"/> <xsd:complexType name="PatternExpression_Type"> <xsd:choice> <xsd:element ref="Pattern"/> <xsd:seque...

JAXB Work-Flow - How Do You Jump into Using JAXB

The JAXB documentation is like a text-book, and I simply don't have to time to learn everything JAXB before I need to use it. I have an XSD, if I want to use JAXB to marshal and un-marshal what is the workflow? I don't need any specifics just a high level view. What I know already: 1. JAXB can be used to take objects and create XML do...

JAXB: how to tell whether a class is Marshalable without annotations

We have a class, with no control over the source, so no way to annotate it for JAXB. We also have a framework to take care of marshaling. Is there any way for this framework to ask that class whether it is marshallable when no annotations are present? ...

Is there any tool to validate @XmlPath annotations ?

Is there any tool to validate @XmlPath annotations used from MOXy JAXB at a specific xml file at compile time from Eclipse or IntelliJIdea java framework or something else? ...

Binding a Generic Java Class to a JSON using JAXB

I have the following java class @XmlRootElement @XmlSeeAlso(DataClass.class) public static class EnvelopeClass<T> { @XmlElement public String version; @XmlElement public T data; EnvelopeClass() { } EnvelopeClass(String version, T data) { this.version = version; this.data = data; } } ...

I'd like to serialize an xml file into java objects

I have this xml file which i want to unmarchal it in a java object.I am using the MOXy JAXB library. test.xml <?xml version="1.0" encoding="UTF-8"?> <project > <type>org.netbeans.modules.ant.freeform</type> <compilation-unit> <package-root>src</package-root> <classpath mode="boot">${...

Create Null Object Unmarshalling Empty Element with JAXB

I am using JAXB (EclipseLink implementation) in a JAX-RS webservice. When an empty element is passed in the XML request an empty object is created. Is it possible to set JAXB to create a null object instead? Example XML: <RootEntity> <AttributeOne>someText</AttributeOne> <EntityOne id="objectID" /> <EntityTwo /> </RootEnt...

Validate JAXBElement in JPA/JAX-RS Web Service

I have a JAX-RS webservice (Jersey) that is a CRUD interface for JPA (EclipseLink) entities. My entities were autogenerated from the database tables and I have annotated them with JAXB annotations so that they can be marshalled/unmarshalled to/from XML. My resource methods take JAXBElement objects as a parameter where required. I don'...

JAXB and complex maps

I am trying to marshal/unmarshal a Map<String, Map<String, Serializable>> via JAXB. There are two problems: 1. JAXB cannot handle complex maps. 2. JAXB cannot handle interfaces (Serializable in this context). How is one supposed to get that through JAXB? ...

Can I customize JAXB @XmlElementWrapper elements for a java.util.Map

Hi, I'm trying to learn to use Map with Jaxb. I did this: @XmlElementWrapper(name = "phoneNumbers", nillable = true) private Map<String, PhoneNumber> phoneNumbers; and the result was: <xs:element nillable="true" name="phoneNumbers"> <xs:complexType> <xs:sequence> <xs:element name="entry" minOccurs="0" maxOccurs="un...

How do I set the xml namespace when using Jersey, jaxb & jax-rs

How do I set the xml namespace when using Jersey, jaxb & jax-rs ...