jaxb

jaxb2-maven-plugin always prints warning when generating beans from XSD

I'm trying to generate beans from an xsd by using the jaxb2-maven-plugin maven plugin, however each time the beans are generated i get the following warning. Note that the result beans work. Does anyone know why this happens? --snip-- [INFO] task-segment: [deploy] [INFO] ---------------------------------------------------------------...

XJC namespace problem

Hello! I am trying to generate java source files from a package of *.xsd files using the xjc code generation tool. The namespaces used in those *.xsd files are as follows: h*p://www.domain.com/foo/bar.x h*p://www.domain.com/foo/bar.x.y h**p://www.domain.com/foo/bar.x.y.z XJC produces packages as follows: com.domain.foo.bar.x and...

IllegalAnnotationsException SetMultimap is an interface, and JAXB can't handle interfaces

I have the following code: private SetMultimap<String, Dynamic> dynamicFields = TreeMultimap.create(Ordering.natural(), new Comparator<Dynamic>() { @Override public int compare(Dynamic o1, Dynamic o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); which gives me the following exception. IllegalAnnotationsException S...

JAXB Ant Task Error: xjc2 [ERROR] null unknown location

When binding on some valid XML documents using Ant's xjc2 task, I get the following failure message: [xjc2] [ERROR] null [xjc2] unknown location The documents are very similar to other files which have bound successfully, all imported schemas exist. Running xjc in verbose mode produced: Parent is not Defined Class...I cannot get the...

thread safety when using spring WebServiceTemplate and Jaxb2Marshaller

I am using spring WebServiceTemplate as a web service client programmatically i.e. without instantiating a spring container. I am using Jaxb2Marshaller for marshaling/unmarshaling. In my application, I create a single instance of the SaajSoapMessageFactory and one instance of Jaxb2Marshaller. I also create a single instance of the WebSer...

XSD anytype and JAXB

Hello, I have an xsd definition (from www.tmforum.org ossj common api v1.5) <element name="primaryKey" nillable="false"> <complexType mixed="false"> <complexContent mixed="false"> <extension base="anyType"/> </complexContent> </complexType> </element> and would like to ...

JAXB to be create a map from XSD

When JAXB generates this, it create the OtherProperties as a List. How can I configure the XSD so it is generated as a Map? <xsd:element name="OtherProperties" minOccurs="0"> <xsd:complexType> <xsd:sequence minOccurs="0" maxOccurs="unbounded"> <xsd:element name="Property"> ...

Java XML Parsing and original byte offsets.

I'd like to parse some well-formed XML into a DOM, but I'd like know the offset of each node's tag in the original media. For example, if I had an XML document with the content something like: <html> <body> <div>text</div> </body> </html> I'd like to know that the node starts at offset 13 in the original media, and (more importantly...

JAXB within an applet - package-info.class not found

We have a web application that uses JAXB from inside an applet. Everything works fine, except when the JAXBContext is first created, we see the following logged in the applet console: Creating JAXBContext... network: Connecting https://myserver.com/MyApp/CC.ccc with proxy=DIRECT network: Connecting https://myserver.com/MyApp/CC.ccc wit...

RESTful 1-N optional relationships

I trying to learn how to write RESTful apps in Java using Jersey and Hibernate, and I'm struggling to understand how to handle parent/child type relationships when POSTing data to a Resource. I'm using JSON to exchange data, but I don't think that's particularly relevant to my problem. The example I'm working with models the relationshi...

Validate against javax bind annotations rather than schema

Been using latest JAXB Sun implementation but can rely on the XJC to generate correct annotations. Have several examples whereby the XJC doesn't attached XMLElement or XMLAttribute annotations for no logical reason. Plus have problems with the logic behind the plugins framework. Anyways I want to ditch the idea of writing schemas just...

Java: Generic JAXB Serialization

I'm looking for a generic way to serialize objects in Java using JAXB XML Serialization. I'd like to have something like this: public static <T> String serializeUsingJAXB(T entity) { JAXBContext context = JAXBContext.newInstance(T.class); // ... } However, it looks as though due to type erasure, T.class doesn't work. What wi...

Substituting one node for another

I'm using docx4j, which uses JAXB. I want to change a Text node to be a Paragraph node (or delete/add in the same place). This may be more of a JAXB question .. I'm not familiar with it. I can find the relevant Text node using MainDocumentPart.getJAXBNodesViaXpath() Looking at samples, I can see how to create a new paragraph node....

Choosing framework for XML persistency

I need to choose a framework for XML persistency of some java classes in our application. My requirements are: 1. I start from java classes, not from schema 2. Using annotations for customization 3. Ability to generate schema. Until now only JAXB seems to satosty all my requirements. XStream does not generate schema JiXB dows not use j...

JAXB: Unmarshal a message using QName?

How can I unmarshal a message that was marshalled using a QName local part different then what is expected? My example is below: Given an object to unmarshal that has been created using a marshal method such as marshaller.marshal( new JAXBElement( new QName("urn:somenamespace","DifferentNameMessage"), ...

JAXB SchemaFactory source order must follow import order between schemas?

Using latest JAXB (Sun) and have a hierarchy of schemas that use import directives between schemas to share type definitions. Schema validation is activated on the setSchema call to Marshaller/Unmarshaller in JAXB which should defer validation to Xerces (using Java 1.5). I don't want to know the order of import directives between schem...

(Java) How can I pass Schema-validated XML documents as parameters between distributed components (e.g. web services or sockets)?

Here is a description of the scenario and I would appreciate also any comments on the approach used The core of my application is a set of web services backed by a P2P database. One service accepts a simple XML-based record (I have designed a generic schema for it). The service processes this data (mainly creating keys based on certain ...

JAXB: Mapping separate date and time elements to one property

I'm working with a XML structure that looks like this: <ROOT> <ELEM_A> <A_DATE>20100825</A_DATE> <A_TIME>141500</A_TIME> <!-- other elements, maybe also other or date/time combinations --> <STRING>ABC</STRING> <ELEM_A> <ELEM_B> <B_DATE>20100825</B_DATE> <B_TIME>153000</B_TIME> ...

Cast JAXB2 generated object to JAXBElement?

I have 2 sets of XSD's, one that generates RPC based calls, and another that defines the product specific methods. The RpcType object (generated by JAXB2) has a 'setRpcOperation' method defined by: RpcType.setRpcOperation(JAXBElement<? extends RpcOperationType>) That 'RpcOperation' object should be the 'specific product method' descr...

Can you optionally serialize a class property through JAXB?

Hello, Is it possible to optionally serialize the properties of a class via JAX-B using using some dynamic flag? e.g. Suppose I Have @XmlRootElement public class TodoItem { private int id; private String title; private String note; // getters, setters } and the following web service operatios: public TodoItem getTodoItemFull...