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
10
votes
11 answers

406 Not Acceptable in Spring MVC application (OSGi, Virgo Web Server) using Jackson, Rome and JAXB2

I just started learning the Virgo Web Server. I'm trying to work with Jakcson JSON in Spring MVC application. At this stage I can not get a GET request serialized object. The server returns "406 Not Acceptable": The resource identified by this…
Alexey
  • 109
  • 1
  • 1
  • 4
10
votes
6 answers

Unmarshalling Error: unexpected element (uri:url, local:"objectname"). Expected elements are <{}objectname>

I'm using jaxb2-marshaller to generate classes to communicate with a webservice. Java-classes are generated with use of some wsdl files. Everything is okay now, but when I'm trying to use some of the generated classes, i got this unmarshalling…
Kornelito Benito
  • 1,067
  • 1
  • 17
  • 38
10
votes
0 answers

Maven generate-sources cannot resolve a dependency

I have a multi-module project in maven which uses JAXB generated sources: parent module A module B (depends on module A) Without JAXB everything compiles fine. When I add the JAXB plugin to module B, maven complains: Failed…
nathan
  • 412
  • 4
  • 8
10
votes
3 answers

Handling invalid enum values while doing JAXB Unmarshalling

My Jaxb has created a Enum class based on the XML schema set up. **enum Fruit { APPLE,ORANGE; }** I am using a SOAP UI to check my web service. Since it is a free form entry, if i give a wrong fruit say "Guva" then instead of throwing an…
sri ram
  • 111
  • 1
  • 1
  • 5
9
votes
2 answers

How to customize package-info.java generated by JAXB2

I'm using org.jvnet.jaxb2.maven2 maven-jaxb2-plugin to generate Java classes from XSD files. I've added -npa so, the plugin doesn't generate anymore package-info.java, but with this option…
ovi2ut
  • 187
  • 1
  • 2
  • 10
9
votes
2 answers

Unmarshalling a Socket's InputStream closes the Socket?

I have a server-client architecture where the client sends an XML to the server who reads it and generates a PDF out of it and sends that back to the client. On the client side: JAXBElement xml = ... Socket sock = ... Marshaller marshaller =…
Kohányi Róbert
  • 9,791
  • 4
  • 52
  • 81
9
votes
1 answer

Validate xml created using jaxb against an xsd file

I have a xml file created using jaxb. I need to validate it against a xsd document. Is it possible to just do validation without unmarshalling. I need to then print the errors in the xml file.
Anand B
  • 2,997
  • 11
  • 34
  • 55
8
votes
1 answer

JAXB: generate Java classes only for a subset of the XSD types

I have a couple of huge XML schema definition (XSD) files and I want to generate only for a subset of the defined types the corresponding Java classes. More precisely I have a list of "root" types that I want to transform into Java classes including…
Joern
  • 1,926
  • 1
  • 13
  • 18
8
votes
4 answers

Two classes have the same XML type name "objectFactory"

We have been using JAXB 2.1 for a long time in our system. We have a platform that is built with Ant and generates a bunch of bundles that are deployed in an OSGi runtime. We use Java SE 6. We use JAXB during the build process to generate datatypes…
Denian
  • 737
  • 2
  • 8
  • 17
8
votes
3 answers

Jaxb: How do I generate ObjectFactory class?

I'm using Java 6, JaxB 2 and SpringSource Tool Suite (same as Eclipse). I had a couple of Java classes I wrote, from which I used JaxB to generate an XML schema. However, I'm noticing in order to use JaxB's ability to generate an XML document from…
Dave
  • 8,667
  • 25
  • 72
  • 90
8
votes
2 answers

convert object into JAXBElement

I want to implement a method which returns JAXBElement following is the code @XmlRootElement(name = "history") @XmlAccessorType(XmlAccessType.FIELD) public class IBHistoryInfo { @XmlElement(name="trade") private List
Hunt
  • 8,215
  • 28
  • 116
  • 256
8
votes
4 answers

JAXB 2.x: How to unmarshal an XML without knowing the target class?

If there is a way, how to do this, I'd like to know the most elegant one. Here is the question: - Let's assume you have an abstract class Z - You have two classes inherited from Z: named A and B. You marshal any instance (A or B) like…
basZero
  • 4,129
  • 9
  • 51
  • 89
8
votes
4 answers

JAXB 2.x : How to override an XmlElement annotation from parent class - Mission Impossible?

Why is this not possible? It seems so simple but it does not behave as expected. Summary: Class A uses an aggregated DataA bean whereas Class B (a subclass of Class A) is using an aggregated DataB bean (whereas DataB extends DataA). I wrote these…
basZero
  • 4,129
  • 9
  • 51
  • 89
8
votes
1 answer

How to transform exceptions into return codes using Spring-WS?

I'm currently facing a problem with error codes and messages using Spring WS. We are using Spring WS 2.0 with a JAXB2 binding and the @Endpoint and @PayloadRoot annotations for convenience. Our endpoint looks like this: @Endpoint public class…
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
8
votes
3 answers

com.sun.istack.SAXException2 : Instance ... is substituting "java.lang.Object", but ... is bound to an anonymous type

I'm upgrading a project to jaxb 2.2.7 from version 1.x. I've got the app working some of the time, but on some responses I see this: java.lang.RuntimeException: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2:…
mdarwin
  • 1,684
  • 7
  • 28
  • 72
1 2
3
49 50