Questions tagged [jaxb2]

For issues relating to the JAXB XML binding architecture, version 2.

Java Architecture for XML Binding (JAXB) is the Java standard (JSR-222) for working with XML as domain objects. It provides an easy to use mechanism for mapping Java classes to XML representations. An implementation is included as part of the Java SE 6 API. There are several implementations available including Metro JAXB (the reference implementation), EclipseLink MOXy, and JaxMe.

741 questions
67
votes
11 answers

JAXB: how to marshall map into value

The question is about JAXB Map marshalling - there is plenty of examples on how to marhsall a Map into a structure like follows: KEY VALUE KEY2
Tim
  • 12,318
  • 7
  • 50
  • 72
58
votes
14 answers

Class Cast Exception when trying to unmarshall xml?

Trying to get past a class cast exception here: FooClass fooClass = (FooClass ) unmarshaller.unmarshal(inputStream); throws this exception: java.lang.ClassCastException: javax.xml.bind.JAXBElement I don't understand this - as the class was…
Vidar
  • 6,548
  • 22
  • 66
  • 96
53
votes
2 answers

Which artifacts should I use for JAXB RI in my Maven project?

Historically, I always used the following JAXB RI artifacts in my Maven projects: com.sun.xml.bind:jaxb-impl - Runtime com.sun.xml.bind:jaxb-xjc - Schema compiler com.sun.xml.bind:jaxb-jxc - Schema generator Since approximately version 2.2.10*…
lexicore
  • 42,748
  • 17
  • 132
  • 221
44
votes
2 answers

How do you customize how JAXB generates plural method names?

We are using JAXB to generate Java classes and have encountered a few cases where generated plural method names are not correct. For example, where we expect getPhysicians we are getting getPhysicien. How would we customize how JAXB pluralizes…
SingleShot
  • 18,821
  • 13
  • 71
  • 101
30
votes
4 answers

Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?

For example, I've got a simple schema which imports another schema. The second schema (urn:just:attributes, just-attributes.xsd) just defines an attribute group.
user197614
25
votes
2 answers

Why has AnnotationReader been removed from JAXB reference implementation?

The class com.sun.xml.bind.v2.model.annotation.AnnotationReader was part of jaxb-impl 2.1.6, but has been removed in 2.1.7. Does anybody know why?
Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
22
votes
8 answers

Netbeans with JAXB Random ClassCastException ..cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

I have downloaded the Soap messages from a SOAP Service and trying to mock the Soap service by returning the downloaded messages. the following code shows how I am Unmarshalling the Soap message into the required Response public static…
Farouk Alhassan
  • 3,780
  • 9
  • 51
  • 74
21
votes
1 answer

Can/Should I list inherited properties for a JAXB mapped bean in the "propOrder" annotation?

I have a bunch of JAXB annotated classes that have a field in common, so I moved that field to a super class, like this public class Base { protected SomeType commonField; } @XmlRootElement(name = "foo") @XmlType(propOrder = { "commonField",…
agnul
  • 12,608
  • 14
  • 63
  • 85
20
votes
1 answer

What is the relationship between Jersey, JAXB, JAX-RS, Moxy, Jackson, EclipseLink Moxy, json and xml?

I am coming from Node.js background and have quite a good understanding of RESTful web services. Now I am trying to build RESTful web services using Java. I understand core Java but completely new to Java based web development. I come to conclusion…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
18
votes
2 answers

Why does JAXB sometimes map to JAXBElement?

There is a placeholder answer over at the unofficial guide with a link to an article which (to me) seems quite unrelated. I use XJC to generate my JAXB classes and while most of them map to each other as expected, some elements get mapped to…
TL Stillman
  • 305
  • 1
  • 3
  • 10
18
votes
4 answers

What is the Jaxb equivalent of a Text node value?

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: value-string-here Does anyone know…
ra9r
  • 4,528
  • 4
  • 42
  • 52
17
votes
2 answers

How to execute the JAXB compiler from ANT

I am using JAXB on a project. the attraction of JAXB is that it is bundled with the JDK, I have been to use xjc.exe on the command line to generate the .java files from a schema. I can't seem to find the JAXB ant task, sure there is a download at…
ams
  • 60,316
  • 68
  • 200
  • 288
16
votes
2 answers

Is there a JAXB Plugin which generates Builders?

Are you aware of any good JAXB Plugin which generated Builder pattern classes for the generated JAXB classes? Composing domain using JAXB generated classes is really nasty. I saw a plugin someone wrote back in 2010 but it doesn't use the newest…
Asaf Mesika
  • 1,643
  • 4
  • 20
  • 33
14
votes
1 answer

JAXB java.util.Map binding

I have a Json response which looks like the following: { "data": [ { "param1": "value1", "param2": "value2", . . . "paramN": "valueN" …
ovunccetin
  • 8,443
  • 5
  • 42
  • 53
14
votes
3 answers

Specify a package instead of "classesToBeBound" for spring Jaxb2Marshaller

I am trying to use Jaxb2Marshaller to marshal a set of java classes using spring. I know this can be done using the following code
Sandeep More
  • 655
  • 1
  • 6
  • 22
1
2 3
49 50