jaxb

How do I marshal a JAXB object to XOM?

I'm trying to figure out what bits I need to plug together to marshal a JAXB POJO to a XOM document, and vice versa. The JAXB Marshaller interface's marshal methods take various targets, such as Result, but none of them have a XOM adapter. Irritatingly, the XOM API does have a XOMResult implementation, but it's package protected, and on...

Enum "does not have a no-arg default constructor" with Jaxb and cxf

A client is having an issue running java2ws on some of their code, which uses & extends classes that are consumed from my SOAP web services. Confused yet? :) I'm exposing a SOAP web service (JBoss5, Java 6). Someone is consuming that web service with Axis1 and creating a jar out of it with the data types and client stubs. They are then ...

Can JAXB generate a generic class?

Can I get JAXB 2.0 XJC compiler to generate a generic class for me? Something as simple as:- public class Shape<T> { T myShape; // getter / setter } I see references for this in the spec but am not sure I'm reading it right. I always get Object references. ...

jaxb - strange problem

Hi, I have a super abstract class: @XmlSeeAlso({AndQuery.class, OrQuery.class, NotQuery.class, PropertyQuery.class, MultiQuery.class}) @XmlRootElement public abstract class Query { This class has a subclass: public abstract class MultiQuery extends Query { and this last super class has also two subclasses: AndQuery and OrQuery an...

JAXB: element is named after type, not property

Web service wsdl contains following schema: <xs:complexType name="DocumentSearchInfo"> <xs:sequence> ... <xs:element minOccurs="0" name="Industries" nillable="true" type="tns:ListCondition"> <xs:annotation> <xs:appinfo> <DefaultValue EmitDefaultValue="false" xmlns="http://schemas.microsoft.c...

JAXB - permGen error on Tomcat server

Hi, I am getting the below error when running my deployed app. Going by the error, it seems JAXB is causing it. Please suggest. java.lang.OutOfMemoryError: PermGen space com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:99) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBu...

Adding static attributes to JAX-B generated elements

Suppose I have a JAXB element like this: @XmlElement private double value; this will generate XML like this: <value>3.14159</value> Now, how do I modify my declaration (or customize JAXB marshalling) to generate XML like this instead: <value type="double">3.14159</value> The type attribute will always have the same value, i.e. "...

Java: JAXB and using char

Hello, I'm working on a project with JAXB but I run into a small problem with JAXB and the char datatype. char gender = 'M'; Translates after marshalling into: <gender>77</gender> So I think that char is mapped to integer, but I simply want to map it to a String. How can I do this? Is it even possible? ...

how to Use JAXWS/JAXB rename the parameter

I use CXF(2.2.3) to compile the Amazon Web Service WSDL (http://s3.amazonaws.com/ec2-downloads/2009-07-15.ec2.wsdl) But got error as below. Parameter: snapshotSet already exists for method describeSnapshots but of type com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetType instead of com.amazonaws.ec2.doc._2009_07_15.D...

JAXB only marshals/unmarshals root node

I am new to JAXB. All I want to do is, given an existing xml string marshal it, and return it in an ejb. The problem is the following code only seems to work for the root node, and not the children. I would like it to work for the whole thing. If it is any help, I have not altered any of the code generated by feeding in the scheme. Any p...

schemagen.exe doesn't skip @XmlTransient annotated class

I annotated a XmlAdapter class like so: @XmlTransient public class DateTimeXmlAdapter extends XmlAdapter<String, DateTime> { but schemagen.exe generates <xs:complexType name="xmlAdapter" abstract="true"> <xs:sequence/> </xs:complexType> so does't skip the class, which was what I expected. XmlAdapter indeed is an abstract clas...

schemagen.exe generates a tns prefix

The tool schemagen.exe generates xsd definitions from classes, e.g. the result is <xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="aa/bb" xmlns:a="aa/bbb" xmlns:tns="aa/bb" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; when I put in package-info.class on the package level: @XmlSchema(namespace = "aa/bb", ...

JAXB - Add a node to the XML as html link

I have a basic JavaBean in my service layer and originally it was not designed for marshalling. This object is used by both JAX-WS, JAX-RS, and Servlets in other layers of my application. I want to take advantage of a drill down type effect in my REST services so my question is: How do I make one of the fields/properties of the javabe...

What is the Jaxb equivalent of a CData Block?

I am looking to convert a class that looks like this ... public class Amenity { public String id; public String value; } into the following XML using JaxB annotations: <amenity id="id-string-here">value-string-here</amenity> Does anyone know what annotation to use on the value member variable to accomplish this? The closest I...

Can you return an array from a JAX-WS @WebMethod?

I'm pretty sure you can, but in addition to answering the question in the title, could you also explain the pros, cons, caveats, if any, to doing so? I know that you can't return a List, Set, Collection, Map, or any interface, from a WebMethod (which is stupid, IMO, but I don't know what the design reasons were should I should probably w...

Can I force JAXB not to convert " into &quot;, for example, when marshalling to XML?

I have an Object that is being marshalled to XML using JAXB. One element contains a String that includes quotes ("). The resulting XML has &quot; where the " existed. Even though this is normally preferred, I need my output to match a legacy system. How do I force JAXB to NOT convert the HTML entities? -- Thank you for the replies....

How can you handle invalid enum types using JAXB?

We are using JAXB to handle our wsdl validation. In the wsdl we have an enumeration like so: <xs:simpleType name="myEnum"> <xs:annotation> <xs:documentation>The enums which matter.</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="MYENUM_1"> <xs:annotatio...

How to generate a Java class which implements Serializable interface from xsd using JAXB?

I would like to introduce caching into an existing Spring project which uses JAXB to expose WebServices. Caching will be done on the level of end points. In order to do that classes generated from XSD using JAXB need to implement Serializable interface and override Object's toString() method How to instruct the xjc tool using XSD to gen...

How to generate @XmlRootElement Classes for Base Types in XSD?

I am having some issues with generating Java Classes with appropriate JAXB annotations from an XSD using XJC. I have a relatively simple XSD file defining my XML schema. The complex types within the XSD take advantage of inheritance using the tags. The problem I having is that I need all complex types to generate Java Classes with the ...

JAXB and multiple object relationships

We are using Jersey (Java REST library) for a project for the last few months and loving it. But this week have run into an issue with JAXB. What I have is an element that has 2 children, each of them have children where some of their children reference each other. Let me show some code. Root root = new Root(); Parent parent1 = ne...