FAQ Database Discussion Community


JAXB Map adapter

java,xml,jaxb
I've problem in converting XML complex type to java.util.Map. While unmarshalling, only the value is getting populated and key becomes NULL. I want the below XML to be converted as java.util.Map<"user_type","students"> but its coming like java.util.Map<NULL,"students">. Can someone please tell why I'm getting the key as NULL? XML <root> <myMap>...

Using custom JAXB context with Jersey client

java,json,jaxb,jersey,jersey-client
I'm using Jersey client 1.8 + JAXB. I want to post a JSON payload that looks like the following: { "transactions": [ { "amount": { "currency":"EUR","total":"1" } ... } ], } I have a DTO that looks like this: @XmlRootElement public class PaymentRequestDTO { @XmlElement(name="transactions") public List<TransactionDTO> getTransactions() { return...

jaxb marxshalling - duplicate elements in the xml

jaxb,marshalling
I have two objects that are in hierarchical relationship. I have the jaxb mapping for setter methods in the child pojo. While loading the xml into pojo I don't have any issues. However, while generating the xml, I see two element entries in the xml for the same attribute in...

JAXB - Move dynamically generated namespaces to document root

java,xml,jaxb,xml-namespaces
I've got this POJO, encapsulating a dynamic, non-nested element of an Atom entry: public class SimpleElement { private Namespace namespace; private String tagName; private String value; private Collection<Attribute> attributes; /* getters/setters/... */ And for completeness, Attribute public class Attribute { private String name; private String value; private Namespace namespace; /*...

JAX-WS with user-defined types

web-services,jaxb,jax-ws,java-ee-7
I am trying to learn about JAX-WS, in particular how to use a complex type. In all three books on Java EE that I have access to, they mention that it is possible, but do not give any example... Strangely, neither search on the web finds one that is complete...

JAX-WS @webMethod manual deserialization

java,xml,web-services,jaxb,jax-ws
I have a SOAP-based endpoint which receives a XML message, validates it and replies with other xml. For xml processing I use JAXB. My endpoint looks like: @WebMethod public SomeOutput processXML(SomeInput input){ ... } Deserealization happens correctly if XML is valid. But I get an exeption if the client sends...

Chunking XML with XMLStreamReader failing

java,xml,jaxb,stax
I am trying to chunk out a big XML into smaller pieces with StAX and JAXB. Here is the sample XML that I am working on: <asset> <entity> <record> <field> <id>remarks</id> <value>ready to test1</value> </field> </record> <record> <field> <id>input_quarter</id> <value>Jun-Sep</value> </field> </record> </entity> </asset> I want to read on record...

Run XJC with maven

java,maven,xsd,jaxb
I want simply generate ‌JAXB object with XJC. It's very easy with command line: xjc -d generated-sources http://www.kbcafe.com/rss/atom.xsd.xml Is there anyway to simply generate the source with Maven. I've tried to use jaxb2-maven-plugin and apache xcf but none of them worked. They did not support URL (just file) and when...

jaxb - add elements to list (maven-plugin)

java,xml,maven,jaxb
I generated my classes with jaxb and now I need to populate some list. What's the best way to do that? pom.xml: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <executions> <execution> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory> <packageName>be.structure</packageName>...

Generating big enum classes with numbers in enum values JAXB, XJC

java,enums,xsd,jaxb,xjc
I'm trying to generate java classes using XJC and I have the following problem: I'm trying to parse this schema which is a big enum type (bigger than default typesafeEnumMaxMembers). So I use following binding: <jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1"> <!-- Raise theEnumMemberSizeCap limit --> <jxb:bindings > <jxb:globalBindings typesafeEnumMaxMembers="2000"/> </jxb:bindings> </jxb:bindings>...

Approaches for populating Java objects from maps

java,xml,serialization,jaxb,deserialization
I'm dealing with a recurring pattern at work. public class SapExample { public static void main(String[] args) { // read SAP data.. // get table List<Map<String, Object>> objects = getTable("ET_WIDGET"); for (Map<String, Object> entry : objects) { Object value = entry.get("WDGT_ID"); String id = (value != null) ? String.valueOf(value) :...

JAX-RS / JAXB : equals()

java,xml,web-services,jaxb,jax-rs
I'm creating a little webservice with JAX-RS and I cannot access to my GET request http://localhost:8080/MyProject/resources/agenda/{jour} Here is my code : package com.project.test; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; import javax.ws.rs.DefaultValue; import javax.ws.rs.PathParam; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.xml.bind.annotation.*; @XmlRootElement(name = "activite") @XmlAccessorType(XmlAccessType.FIELD)...

MessageBodyWriter not found for media type={application/xml, q=1000} - Jersy + Jaxb

rest,jaxb,jersey,jax-rs
I am writing a RESTful web service with Jersy. I want to return a custom object in XML form to consumer. The error I am getting is - MessageBodyWriter not found for media type={application/xml, q=1000}, type=class com.test.ws.Employee, genericType=class com.test.ws.Employee. Below is the code: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"...

Null Pointer Exception in JAXB RI ClassFactory

java,xml,nullpointerexception,jaxb,unmarshalling
Intro My friend and I are working on a JavaFX application that acts as a planner for our school. We have tasks (homework for classes), events, courses and student info. In an attempt to store data persistently on the user's hard drive we are using JAXB. We have annotated our...

JAXB Element Wrapper for a Single Group of Elements When Marshalling

java,xml,jaxb
I wish to have an XML structure like this: <?xml version="1.0" encoding="UTF-8"?> <MSG> <CASE> <Field1></Field1> <Field2></Field2> </CASE> </MSG> The problem is, with the @XmlElementWrapper, I need a collection of items but there will be only 1 case item. How can I have multiple root elements, for a single collection of...

JAXB: Child Element Returning from WebServiceTemplate is null

java,spring,web-services,jaxb
I am using string-ws to create webservice client and fetching data from the webservice. I have used org.jvnet.jaxb2.maven2:maven-jaxb2-plugin to generate the java classes. Some of the classes are given below generated by this plugin: GetLandingPageFAQ: import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getLandingPageFAQ", propOrder = { "faq" })...

Exclude processing instruction from XSLT

java,xml,xslt,jaxb,jaxb2
I have a simple plain-text-generating XSLT that I am applying like this (using the reference implementation): StreamSource schemasource = new StreamSource(getClass().getResourceAsStream("source.xml")); StreamSource stylesource = new StreamSource(getClass().getResourceAsStream("transform.xslt")); Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesource); StringWriter writer = new StringWriter(); transformer.transform(schemasource, new StreamResult(domWriter)); System.out.println("XML after transform:");...

jaxb: I use different method but all doesn't work

web-services,jaxb,jaxb2
I want to output a XML like this: <master> <list type="array" nil="true"> <master> I have tried @XmlAttribute and @XmlElement(nil=true), how should do this with jaxb. <slave-status><connect-retry type="integer" nil="true"/> <created_at type="datetime" nil="true"/> <slave-status> ...

JAX-WS: Compile Schema separate from WSDL

java,xsd,jaxb,wsdl,jax-ws
If have a rather large schema that is used in several webservices, therefore I want to separate XSD compilation from WSDL compilation. In a simplified example, compiling in a single step works: $ wsimport -verbose service.wsdl parsing WSDL... Generating code... org/example/wsdl/mysvc/MySvcPortType.java org/example/wsdl/mysvc/MySvcService.java org/example/ns1/Element1.java org/example/ns1/ObjectFactory.java org/example/ns1/package-info.java ... Compiling the xsd and...

Jaxb - How to avoid “xsi:” at root element

java,xml,xsd,jaxb
Im using Java 7 and trying to create an xml from an xsd with jaxb. I generated Java classes from xsd. class1: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "vnr", "meldungsart", "teilnehmeranzahl", "email", "teilnehmer" }) @XmlRootElement(name = "Veranstaltung") public class Veranstaltung { @XmlElement(name = "VNR", required = true) protected String...

Generate JAXB episode file with Gradle anttask

ant,gradle,jaxb,build.gradle
I set up a gradle task to generate java classes from XSD files: ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath) ant.jaxbTargetDir = jaxbTargetDir ant.xjc(destdir: '${jaxbTargetDir}', package: 'com.example') { schema(dir:'/home/bruckwald/proj/schema/xsd', includes: '*.xsd') } How can I pass the argument -episode my.episode to the ant task so that the episode file will be...

Maven trouble when trying to generate from WSDL file

eclipse,soap,jaxb,wsdl,maven-jaxb2-plugin
Im trying to generate sources from a wsdl file, but I keep running into an error on my pom.xml that I believe might be my issue? Below is the error that I get from my pom, and my pom file. Also I cannot build the project with "mvn clean install"....

WSIMPORT- Unable to Generate non static inner classes in Client stubs

java,web-services,jaxb
I exposed a Web service written with Java. My Schema has Complex Types objects. Everything is fine. When generate Client stubs with WSIMPORT command I noticed here are static inner classes in the generated client stubs . To avoid generating inner classes tried with JAXB, XJC -> create multiple class...

whether there can be XML, appropriate XSD, having choice with maxOccurs = “1” and every elements with minOccurs=“1”?

xml,xsd,jaxb
I have valid XSD, But i can't make xml, appropriate it. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <xs:schema xmlns="urn:hl7-org:v3" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:hl7-org:v3" elementFormDefault="qualified"> <xs:element name="Main" type="Main"/> <xs:complexType name="Child1"> <xs:sequence> <xs:element name="f1" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="Child2"> <xs:sequence> <xs:element...

JAXB How to append and XML String into a XML element?

java,xml,jaxb
I'm trying to add an element of XML , another XML that is a string . The problem comes when I generate the XML file coding is not correct and it makes me values ​​< > HTML. JAXBContext jaxbContext = JAXBContext.newInstance(ExpedienteType.class); String XMLDatosEspecificos = "<![CDATA[" + XMLDatosEspecificos + "]]>"; expedienteType.setDATOSESPECIFICOS(XMLDatosEspecificos);...

JAXB support for SOAP style arrayType

java,xml,web-services,soap,jaxb
I'm trying to make a new version of a server that previously used Axis 1.4 to respond to SOAP RPC requests using Spring-WS. I have a few of the RPC calls working, but I'm stuck trying to satisfy a request that expects a SOAP body that looks like this: <rpcCallResponse...

XSD from XML Java Jaxb

java,xsd,namespaces,jaxb
I need to generate in Java the xsd file which using jaxb maven plugin (http://mojo.codehaus.org/jaxb2-maven-plugin/xjc-mojo.html) will produce an XML like the following: <data xmlns = "http://foo.com"> <childData xmlns = "http://bar.com" /> </data> I don't want to edit the jaxb autogenerated classes or something like that. I've already checked similar topics...

Spring Boot RequestMapping with non-standard produces value returning 406 error when returning JAXB annotated object

spring,spring-mvc,jaxb,spring-boot
I'm creating a Spring Boot app to replace a legacy api application, so all the routes/headers/etc are already set in stone. In that legacy app we used custom Accept headers to include both the version and the content type. So our Accept header is like: catalog.v1.xml or catalog.v2.json etc. Here...

JAXB Release Documentation stating contrary information about Compile and Runtime Jars

java,xml,jaxb,jax-ws,maven-3
Referred to the following JAXB release documentation. https://jaxb.java.net/nonav/2.2.11/docs/release-documentation.html#section-2232462900667844 It states that it needs following jars at Runtime jaxb-api.jar, jaxb-core.jar, jaxb-impl.jar, But in the next line, same documentation also states that it does not needs same jars at Runtime. This seems incorrect information. What is correct information? Where can it be...

XML parsing with java, with out using pre-defined libraries [closed]

java,jaxb
Can Someone tell me , How to do XML parsing with java (JAXB).

How to read objects (Polymorphic) of the chosen class, from the XML using JAX-B

java,list,jaxb,polymorphism
I created a list of polymorphic objects. I can convert them into XML and vice versa (marshall and unmarshal using JAXB.) But I would like to read only the objects from the chosen class. I used a few tutorials about converting object lists by JAXB, for example this one: http://memorynotfound.com/convert-xml-to-polymorphic-object-using-jax-b/...

Set MOXy as JAXB Provider without properties file in the same package

java,json,jaxb,marshalling,moxy
I am trying to use MOXy as my JAXB provider in order to marshal/unmarshal content into XML/JSON. I have created the "jaxb.properties" file with as content : javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactor Everything works fine. JAXBContext jaxbContext = JAXBContext.newInstance(ServerInformation.class); // The jaxb.properties must be in the same package as "ServerInformation.java" Marshaller marshaller = jaxbContext.createMarshaller();...

JAXB generated classes of certain types implementing a custom interface

jaxb,jaxb2,xjc,scd
I am working on an application that uses XJC to generate Java POJOs from XSDs. There are dozens of schemas, and that number will grow. The application also needs to be able to handle different versions of the same schema, which means that I will have multiple schemas defining common...

XMLGregorianCalendar not displayed in the right format when marshalled

java,xml,date,jaxb,marshalling
I'm getting some dates from the database, putting them into objects of classes derived from an XSD schema using JAXB and then marshalling the objects to an XML file. One of the derived classes has an XMLGregorianCalendar field, and I want the date that I put there to be written...

CXF Webservice response with XML content

java,xml,web-services,jaxb,cxf
I have an existing CXF Java webservice which returns a deep, complex, nested response type. Parts of the response type exists in the DB stored as plain XML message (the exact same XML what should get returned). Example response type: PartyResponse -> PartyRec -> PartyInfo and PartyInfo structure is stored...

Object must have some value in its @XmlValue field

java,jaxb
I have the following code @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "udt_TextType", propOrder = { "value" }) @XmlSeeAlso({ RoadTypeCodeTypeType.class }) public class UdtTextType { @XmlValue @XmlJavaTypeAdapter(NormalizedStringAdapter.class) @XmlSchemaType(name = "normalizedString") protected String value; /** * Gets the value of the value property. * * @return possible object is [email protected] String } * */ public...

maven-jaxb2-plugin maven generation sun-jaxb.episode

java,maven,jaxb,maven-jaxb2-plugin
I want to remove comments inside generated files through maven-jaxb2-plugin. I tried: <noFileHeader>true</noFileHeader> and <configuration> <args> <arg>-no-header</arg> </args> </configuration> It boths works for java classes, but doesn't work for sun-jaxb.episode which keeps the comment with the timestamp. Thank you, RoD...

JAXB Unmarshalling with outer and inner tags having same name and different attributes

java,xml,jaxb,unmarshalling
<xyz> <a attributeA, AttributeB> <b> </b> <c> <a attribute1,attribute2,attribute3/> </c> </a> </xyz> can anyone suggest me how to deal with 'a' innertag. ...

How to parse attributes in a nested node with JAXB?

java,xml,jaxb
I'm trying to parse a XML file created with the omdbAPI. The XML-file looks like this: <?xml version="1.0" encoding="UTF-8"?> <root response="True"> <movie title="Fifty Shades of Grey" year="2015" ... plot="..." imdbRating="4.2" imdbID="tt2322441" type="movie" /> </root> And my class that JAXB uses looks like this: @XmlRootElement(name = "movie") public class IMDBInfo {...

MOXy not able to marshall UTF-8 characters correctly with application/json

json,encoding,utf-8,jaxb,moxy
I got really stuck with Eclipselink MOXy 2.5.1 not delivering me correctly encoded Asian characters (or other ones, e.g. German umlauts äöü). My code: @GET @Produces({MediaType.APPLICATION_JSON + ";charset=UTF-8"}) @Path("/test") public Response getJson() throws IOException{ return Response.ok(new Test()).build(); } @GET @Produces({MediaType.APPLICATION_JSON + ";charset=UTF-8"}) @Path("/test2") public Response getKey() throws IOException{ return Response.ok(new...

XSLT processing with jaxb for a small transformation performance

java,performance,jaxb,xslt-1.0
I have a simple transformation. I have a java object to transform into different java object. so i used xslt. jaxb is my processor. TransformerFactory transformerFactory = TransformerFactory.newInstance(); StreamSource streamSource = new StreamSource( new File("conv.xsl")); Transformer transformer = transformerFactory.newTransformer(streamSource); JAXBContext jc =JAXBContext.newInstance(Bags.class); JAXBSource jAXBSource = new JAXBSource(jc, device); jAXBResult =...

JAXB - How to specify xml attributes in binding Java Class

java,xml,jaxb
I know to create a JAXB Class to marshal/unmarshall an xml like this <outertag> <innerelement> <innerElementDetail1>some value</inner-element-detail1> </innerelement> </outertag> here is the class I created @XmlRootElement(name ="outertag") @XmlAccessorType(XmlAccessType.FIELD) public class OuterTag { @XmlElement(name = "innerelement") private List<InnerElement> innerElemements public static InnerElement{ private String innerElementDetail; // getters and setters } }...

How to get the requested contenttype of a REST-Request?

java,rest,jaxb,jax-rs
Using JAXB for implementing a REST-Webservice, we have several methods that are producing output. The class that contains all of these methods is annotated with @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }). If a request goes the happy-path (no errors occur), we return the POJO's in our methods and JAXB dynamically marshalls these...

How to map a XML ignoring namespace using JAXB?

java,xml,jaxb,xml-namespaces,unmarshalling
I'm receiving a XML from a web service with the following format: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <string xmlns="http://someurl.com">somethingheresomethinghere</string> And I'm trying to unmarshall this to a POJO that looks like this: @XmlRootElement(name="string") public class StringValue { @XmlValue private String value; public StringValue () { } } And my unmarshalling code...

Jaxb generate classes from xsd:s with common include fails

java,xsd,jaxb
I'm trying to generate classes from a bunch of xsd:s that all include the same common schema which simplified looks something like this: Schema1.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace"> <xsd:include schemaLocation="common.xsd"/> ..... </xsd:schema> Schema2.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace"> <xsd:include schemaLocation="common.xsd"/> ..... </xsd:schema> and the common schema does not define a...

JAXB - How to unmarshall XML without XSD which contains lists without wrappers

java,xml,jaxb
I have a complex XML file which I must parse, but I don't have any XSD. The XML looks like this (simplified): <?xml version="1.0" encoding="UTF-8"?> <mets:mets ... namespace declaration ommited ... > <mets:metsHdr> complex mets:metsHdr </mets:metsHdr> <mets:dmdSec> complex mets:dmdSec 1 </mets:dmdSec> .... <mets:dmdSec> complex mets:dmdSec n </mets:dmdSec> <mets:fileSec> complex mets:fileSec...

How to save a Singleton Object to an XML file using JAXBContext?

java,xml,jaxb,singleton
I am looking to save a Singleton Object to an XML file using JAXBContext. The Object in question is called Player which is extending an abstract class Entity. Entity does also extend Thread. Since Player is a Singleton Object, its constructor is made private and and unaccessible from outside the...

JSON, JAXB,JSON Rest

json,rest,jaxb,jackson
I created a Rest Service which has is working fine in XML request ( Rest Service input JAXB generated class ). When I am trying to send a Json Request, It's throwing an exception. SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the...

How to obtain the runtime type from an object in java

java,jaxb,marshalling
I have this code: public void doSomething(Integer param){ . . . JAXBElement<Integer> jaxb = new JAXBElement<Integer> (new QName("uri","local"),Integer.class, param); . . . } And I want it to be more flexible. I need the parameter to be of type Object, but I don't know how to change this line: JAXBElement<what_do_I_put_here>...

How to use a class customization to resolve conflict when generating jaxb object from xsd

java,xsd,jaxb,ifc
When I run the xjc -d src/ -p com.test IFC2X3.xsd command on following xsd it gives the conflict. .... <xs:element name="IfcCondenserTypeEnum" nillable="true"> <xs:complexType> <xs:simpleContent> <xs:extension base="ifc:IfcCondenserTypeEnum"> <xs:attributeGroup ref="ex:instanceAttributes"> </xs:attributeGroup> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:simpleType name="IfcCondenserTypeEnum"> <xs:restriction base="xs:string">...

How to get xml attribute and values using JAXB

xml,parsing,jaxb
I am new in Jaxb i have one xml file which contain many attribute so i want the attribute with value My XMl <message_mapping> <message Rtype="DIAGNOSTIC" direction="2" name="Diagnostic" mode=""> <field tag="USERNAME" source="I" tranData="username" required="false" dataType="string" defaultValue="" /> <field tag="PASSWORD" source="I" tranData="password" required="true" dataType="string" defaultValue="" /> <field tag="LOCALDATETIME" source="E" tranData="trxDateTime" required="true"...

How to ignore elements/attributes in XML when mapping to objects using JAXB?

java,xml,jaxb
I'm working with mapping XML strings into POJOs and viceversa using JAXB 2.0, and I want to be able to determine the elements in a XML that should be mapped into my annotated POJO classes. Let's say I have the following XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customer id="1"> <firstName>Peter</firstName> <lastName>Parker</lastName>...

How to accept xsd vs xml validation when elements having null values

java,xml,validation,parsing,jaxb
I have a xml and have to validate against xsd for the structure and data type. but Some fields in the xml has null/empty values. But when using JAXB for validating the xml "cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'." This exception is thrown from JAXB exception with...

Efficiently unmarshaling a part of a large xml file with JAXB and XMLStreamReader

java,xml,jaxb,xmlstreamreader
I want to unmarshall part of a large XML file. There exists solution of this already, but I want to improve it for my own implementation. Please have a look at the following code: (source) public static void main(String[] args) throws Exception { XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xml =...

xsd to java bean jaxb field name

java,xsd,jaxb
I have created java beans from the following xsd files person.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified" jxb:version="2.0"> <xs:annotation> <xs:appinfo> <jxb:globalBindings> <jxb:serializable uid="1"/> </jxb:globalBindings> <jxb:schemaBindings> <jxb:package name="com.thiyanesh"/> </jxb:schemaBindings> </xs:appinfo>...

Use JAXB to parse a XML file as a stream

java,xml,jaxb
I have a XML file which contains a lot of employees record (say up to 1M) as follows: <employee> <name>peter</name> <mobile>435432</mobile> <employee> <employee> <name>Mary</name> <mobile>324213</mobile> <employee> <employee> <name>May</name> <mobile>54342423</mobile> <employee> I map an employee record using JAXB to the following Java object: @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "employee") public class Employee...

XSD to HTML form

java,json,xml,xsd,jaxb
What I want to do: I'm basically trying to create a tool which generates a HTML form where the data can be entered, which gets stored in the corresponding XML file. The HTML form in itself needs to be created with the help of the given XSD. Problems I faced:...

Unmarshalling indented XML gives different result in Java 7 vs 8

java,xml,jaxb
Switching to Java 8 made one of my tests fail. Here is a condensed example: public static class Wrapper { @XmlMixed @XmlAnyElement(lax = true) public List<Object> content; } public static void main(String[] args) throws XMLStreamException, JAXBException { final String xml = "<a>\n <b/>\n</a>"; final XMLInputFactory xif = XMLInputFactory.newFactory(); final XMLStreamReader...

Jersey 2 (JAXB) XML element case with list not honoring XmlRootElement

xml,jaxb,jersey,jersey-2.0
We just upgraded a service from Jersey 1.x to 2.10.x and are seeing some unexpected behavior. We have a class like this that is annotated to marshal as 'User' instead of 'user': @XmlRootElement(name = "User", namespace = "security.services.pml.com") public class User { @XmlElement(namespace = "security.services.pml.com", required = true) protected String...

JAXB and matching property names

java,xml,xsd,jaxb,code-generation
I am trying to use the XJC utility to generate classes from an XSD file. It works OK except when looking into my generated class i get: * You are getting this "catch-all" property because of the following reason: * The field name "Products" is used by two different parts...

Can't find SOAP headers after spring integration marshalling

web-services,soap,jaxb,spring-integration
I'm trying to create an inbound gateway for a SOAP service, that accepts SOAP requests like the following: <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header> <RequestHeader xmlns="http://test.com/"> <SecurityToken>mytoken</SecurityToken> <RequestID>1234</RequestID> </RequestHeader> </S:Header> <S:Body> <BaseRequest xmlns="http://test.com/"> <RequestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...

Jersey JAX-RS 3 level nested object has null value

jaxb,jersey,jax-rs,jersey-2.0
I have the below JSON code that needs to be parsed. I'm using the corresponding JAX-RS models. The problem is that the paymillClient object is null. If I add currency as a string inside the PaymillSubscription object, it returns EUR value, not null. So there appears to be a problem...

IllegalStateException when unmarshalling from child node with XMLEventReader

java,xml,jaxb
I'm working with some .xml and stumbled in a never seen before exception. Here is the broken code: public class UnmarshallProva { public static void main(String[] args) { JAXBContext jaxbCx; Unmarshaller mavByXml; FileReader fr; XMLInputFactory xif; XMLEventReader xer; int mavv = 0; try { jaxbCx = JAXBContext.newInstance(MavType.class); mavByXml = jaxbCx.createUnmarshaller();...

jaxb2-annotate-plugin not working

java,jaxb,maven-plugin,jaxb2-annotate-plugin
I want to generate "@java.lang.SuppressWarnings("all")" before the generated "Doc" class. Problem: jaxb2-annotate-plugin don't generate annotations. My pom.xml: ... <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>xjc</id> <goals> <goal>xjc</goal> </goals> <configuration> <extension>true</extension>...

StAX with JAXB XML parsing Only Parsing first instance

java,xml,jaxb,stax
Hi I have an XML structure like this: <?xml version="1.0" encoding="UTF-8"?> <response> <result> <name>Chrome</name> <version>2</version> </result> <result> <name>IE</name> <version>8</version> </result> </response> I am trying to use staxx to parse out just the stuff in the middle with JAXB. The problem I am getting is that it isn't getting all result...

How to change that the JAXB Marshaller creates a datetime string even though the XSD demands a date?

xml,date,datetime,xsd,jaxb
We are using JAXB to parse a LocalDate object into XML. Even though the XSD specifies the target field to be xsd:date the Marshaller writes a xsd:datetime string into the Stream. What is the best way to correct this?...

JAXB Webservice migrating from Weblogic 10 to 12

java-ee,jaxb,weblogic
I have a running webservice (JAX-WS 2.2) on a Weblogic 10.3. Everything works fine. So there can't be the problem in the wsdl. I try to migrate to WLS 12. But now I get erros while deplyoment. What has changed from WLS 10 to WLS 12 which yould cause the...

IntelliJ doesn't recognize import statements for JAXB classes

java,maven,intellij-idea,jaxb,jaxb2
I'm using IntelliJ IDEA 14 as IDE and jaxb2-maven-plugin for creating Java classes from XSD files. When compiling my module with Maven no errors are displayed. Even when using the command make or compile in IntelliJ no errors are displayed in the status popup. But in the files itself and...

How to make changes in marshalled output in Java web service client

java,xml,jaxb,cxf,jax-ws
I am trying to interact with a third party web service, who requires me to send a security token as a part of each request. The token is a node by itself, and I acquire it from the response of an initial call. The web service endpoint is dotNet, and...

Jersy 2 Client + JAXB (MessageBodyWriter not found)

java,jaxb,jersey
I'm trying to use Jersy 2 in client mode to post XML to a server but i always get an exception. I have got only one dependency in my pom file: <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.18</version> </dependency> My Java code: public static void main(String... args) { Client client = ClientBuilder.newClient(); WebTarget...

JDK Cross Compilation uses which version of JAX WS and JAXB?

java,maven,jaxb,jax-ws,cross-compiling
I have JDK 8 installed on my machine. My code's POM has a Maven Compiler Plugin which uses source value as 1.7 and target as 1.8 I have JAXWS and JAXB dependency in my code. JDK 8 comes bundled with 2.2.9 version of JAXWS and JAXB. JDK 7 with 2.2.4...

Pass absolute file path from java code to xslt document()

java,xml,xslt,jaxb,xslt-1.0
In my xslt I'd like to look up an xml file. I need to pass the path to this file from java code.I have the followings: ... Transformer transformer = TRANSFORMER_FACTORY.newTransformer(); transformer.setParameter("mypath", "/home/user/repository"); xslt: <?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:param name="mypath"/> ... <xsl:template match="connection[@id]"> <xsl:variable name="lookupStore"...

How to make JAXB to annotate and provide equlas/hash code implementation

java,xml,jaxb
I am trying to use JAXB to generate classes from WSDL which are annotated with Jsr303Annotations and provide implementation of equals and hashcode. Both of these work separately, however when i try to achieve both requirements then i get error: An internal error occurred during: "Building workspace". com.sun.tools.xjc.Plugin: Provider org.jvnet.jaxb2_commons.plugin.fixjaxb1058.FixJAXB1058Plugin...

JAXB: Can't work around collision in ObjectFactory class error

java,xsd,jaxb
I have a couple of SOAP services (implemented in .Net) that I want to generate a Java stub for. The first service was no problem but the second service threw up the error WSDLToJava Error: http://localhost/AMS52/ServiceManagement.svc?xsd=xsd8 [0,0]: Two declarations cause a collision in the ObjectFactory class. http://localhost/AMS52/ServiceManagement.svc?xsd=xsd11 [0,0]: (Related to...

Ignoring incoming json elements in jax-rs

json,jaxb,jax-rs
I'm wondering where to put the @JsonIgnoreProperties(ignoreUnknown = true) in a Java REST API. I have the following class: import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.ObjectMapper; @JsonIgnoreProperties(ignoreUnknown = true) public class QueuePayload { private String message; private String id; public String getId() { return this.id; } public String getMessage() { return this.message; }...

Setting column length on generated JPA model with Hyperjaxb

maven,jpa,jaxb,hyperjaxb
On my current project, I need to deal with a set of XML files containing some financial information and, later on, do some complex queries on that data in order to populate a database schema. Those XML files are XSD based and I used Hyperjaxb3 maven plugin to generate JPA...

jaxb: strange class cast exception on enum list

java,xml,jaxb,java-8,oxm
I am using jaxb to generate java classes from an xsd file. The xsd contains a definition of an element of which the content is a list of constants defined in the same xsd as enumeration. When the classes are generated using the JAXB reference implementation from the oracle's jdk1.7...

JAXB Large byte[] field

java,jaxb
I have a problem where I have to process an XML that has a large binary content. Usually I would define the model class like this: @XmlType public class DataContainer { byte[] content; // getters/setters } Now with content in the magnitude of ~1GB un-/marshalling becomes a major issue. Do...

@XmlElementWrapper isn't working for me

xml,jaxb
this is my definition that don't retrieve the list of elements in the wrapped elements: @XmlElementWrapper(name = "channels") @XmlElement(name = "channel") private ArrayList<Channel> expChannels; public ArrayList<Channel> getChannels() { return this.expChannels; } public void setChannels(ArrayList<Channel> listOfChannels) { this.expChannels = listOfChannels; } And this is the declaration of Channel model object: @XmlRootElement...

Unable to load an xlxs spreadsheet into eclipse

java,eclipse,jaxb,docx4j
I want to implement a java desktop-application using eclipse that takes the information from the user and saves it into excel spreadsheet (using docx4j), but I faced a problem at the very beginning. I'm trying to load the spreadsheet using this code: private static void load(String filepath) { SpreadsheetMLPackage exc;...

Null values for nested items unmarshalling in JAXB/MOXY

java,xml,jaxb,moxy
JAXB is unmarshalling the first elements encountered of each type in an XML document fine but leaving the children of any nested elements of the same type null. Briefly, the problematic structure is as follows: sequence->media->audio->track->clipitem(->sequence etc etc) So, a clipitem may also have a nested sequence, and the whole...

Mule JAXB Object to XML Transformer throwing JAXBException

java,xml,jaxb,mule
I am using Mule 3.6. I have an object which is annotated with JAXB bindings and I am trying to convert it into XML in Mule. Whenever I try to do so, I get a javax.xml.bind.JAXBException: "com.mj.metal.object" doesn't contain ObjectFactory.class or jaxb.index. My transformer are defined as: <mulexml:jaxb-context name="JAXB_Context" packageNames="com.mj.metal.object"/>...

hyperjaxb3 add extra columns (ie creation timestamp)

java,hibernate,xsd,jaxb,hyperjaxb
I'm trying to add an extra column, using binding file to a model obtained from a xsd (a big one). The added field need to be persisted, but not serialized. I tried with hj:generated-property but it does nothing with it. To give a sample of what I tried so far,...

Can I unmarshal a single xml property to a multi element array?

java,arrays,xml,jaxb
Given the following xml code: <root> <vector>{1, 2, 3, 4, 5}</vector> </root> Is it possible to unmarshal the element <vector> into a 5 element array, such that: array = {1, 2, 3, 4, 5} In my attempt to do this I have written some code, but it fails to correctly...

exception unmarshalling xml file using jaxb

java,xml,xsd,jaxb
I'm trying to unmarshall an xml file, but I get a binding exception, I'm new to using xml and schemas with java, but from what I can tell, it looks like a problem with the namespaces when it tries to bind the xml to an xsd schema I'm using. I've...

Unmarshalling multiple XML elements to one field using JAXB

java,xml,jaxb
I have an XML file in format described below. I'm currently using JAXB to unmarshall the XML elements (event) to Java objects (Event). All properties work fine, except one... As you can see in the XML, the date element stores only the date and the time stores only the time...

How to define model to unmarshall post data without root element name

spring,rest,jaxb,cxf,jax-rs
I have a REST API which gets following in post request body to create that data in back end: { "key": "mykey30", "value": "my long value" } and this is how I defined my model: @XmlRootElement public class Entity { private String key; private String value; } and this is...

How to marshall large java objects to xml without heap error?

java,xml,jaxb,marshalling
Currently I am using JAXB marshaller to marshall the lasrge java object and it is working but when i recive the large java object application is throwing the OutOfMemoryError: heap space error. Can some one let me know how to marshall large java object to xml without heap error. StringWriter...

XSD mapping to Java POJOs

java,xml,xsd,jaxb
Let's say I have an XML source from a web service, that I have no control over, with the following structure: <wrapper> <baz>content</baz> <foo> <bar>content</bar> <bar>content</bar> </foo> </wrapper> The corresponding XSD is the following: <xsd:complexType name="wrapper"> <xsd:element name="baz" type="xsd:string"/> <xsd:element name="foo" minOccurs="0" maxOccurs="1"> <xsd:complexType> <xsd:sequence> <xsd:element name="bar" type="xsd:string"...

Instantiate web service

java,jaxb,wsdl
I have clasess BankImpl, BankService, BankClient, BankServer and Bank interface. I want to instantiate that bank service so I can use it with my other webservices but dont know the correct way of doing it. I have something like this now: Service service = Service.create(wsdlLocation, new QName("http://bla/bla/bank", "BankService")); Bank bank...

Unmarshalling SubElements from XML Response

java,jaxb,unmarshalling
I am trying to unmarshall a XML Response. It is in the following structure <employee> <name> David </name> <age> 33 </age> <dateofjoin> <year>2012</year> <month>10</month> <day>01</day> </dateofjoin> </employee> Following is my Employee Class public class Employee { private Dateofjoin dateofjoin; private String name; private String age; public Dateofjoin getDateofjoin () {...

jxpath not honoring JAXB's XmlElement name of xjc-generated classes

jaxb,jxpath
I use an XML Schema Definition and JAXB to generate Java classes with proper @XmlElement or @XmlRootElement annotations. Since the schema has some deep nesting in it (not my choice), I'd rather use jxpath to access deeply buried classes using an XPath (rather than cumbersome daisy-chain of .getThat() and that...

JAXB: Unmarshal heterogeneous array

java,json,jaxb,unmarshalling,moxy
I'm trying to unmarshal using MOXy a json with the following structure: [ { "page": 1, "pages": 1 }, [ { "indicator": { "id": "IC.BUS.EASE.XQ", "value": "Ease of doing business index" }, "country": { "id": "1A", "value": "Arab World" }, "value": "113.952380952381", "date": "2014" }, ... ] ] The first...

JAXB - how to create xml from object with elements

java,xml,jaxb
I have a class similar to: @XmlRootElement public class myObject{ String name; String age; String value; public String getName() { return name; } @XmlElement public void setName(String name) { this.name = name; } public String getAge() { return age; } @XmlElement public void setAge(String age) { this.age = age; }...

XML/JSON processing

xml,json,dom,jaxb,jackson
I am writing a set of REST APIs to XML and JSON content type for my application. I would like to make an informed choice of XML/JSON processing libraries while designing and implementing these APIs. Following are various non-functional requirements for APIs: Performance - The APIs deal with huge amount...

MarshallingWebServiceOutboundGateway with JAXB marshaller throws error

java,spring,jaxb,spring-integration
I'm using spring-integration 4.1.2-RELEASE, and am having a bit of problems with a MarshallingWebServiceOutboundGateway. I'm attempting to make a SOAP call to a SOAP webservice, having used JAXB to generate the object representation of the wsdl. My auto wiring and flow looks like this: @Autowired MarshallingWebServiceOutboundGateway securityService; @Autowired HttpRequestExecutingMessageHandler documentService;...

JAXB not parsing default namespace correctly

java,jaxb,gpx
I'm writing some code to parse GPX files. These are produced by a number of different sources, from route planning websites to satnav recordings. I'm having trouble with JAXB. It seems that it won't load the file if it uses the default name space. For example when I try to...

JaxB rename class with duplicate name

java,xml,xpath,xsd,jaxb
I have to use a schema which contains the following snippet where the name object is duplicated. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="param_object_type"> <xs:sequence> <xs:element name="object" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="object" minOccurs="0" maxOccurs="unbounded"> </xs:sequence> </xs:complexType> </xs:sequence> </xs:complexType> </xs:schema> Jaxb was originally...

What is the latest official version of XJC and where can I get it?

java,xml,jaxb,xjc
XJC (XML Java Compiler) is part of JAXB (Java XML Bindings). If I look at the official website, the latest version of JAXB seems to be 2.2.11. That's the one you got when you just install the latest JDK version 8u40. The following output shows the version of XJC related...

JAXB Marshalling Child Class inheritance

java,inheritance,jaxb
I have an object (Department) which will be the root element. It has an aggregated object (Employee) which has two specialisations (Manager and FactoryWorker). If I set Employee to one of the specialised objects then only the Employee object attributes are marshalled. I'd appreciate any tips. e.g. @XmlRootElement(name="department") class Department...