jaxb

Binding a JSON to a Java class using JAXB

I have the following JSON, where can be either true or false: {"flag1":<boolean value>, "flag2":<boolean value>} And I have tried to bind it to a Java class using Jersey and the following JAXB annotations: @XmlRootElement public class MyClass { @XmlElement(name = "flag1", type = Boolean.class) private Boolean flag1; @Xml...

Java/JAXB error in Matlab when using unmarshal function

Hi, I'm running into a problem that I think is related to updating JAXB to the latest version. I'm running a marshal command that returns: ??? Java exception occurred: javax.xml.bind.MarshalException - with linked exception: [java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String] at com.sun.xml....

apache camel Client Using Producer Template versus Client Using Spring Remoting PROXY

Hello! I'm trying the Apache Camel Tutorial JmsRemoting. Following the examples, the proxy client works fine to template and proxy clients configuration. But, when i change the example in order to use a JAXB transportation object xml, configuring routes with marshal and unmarshal dataformats, the situation become different. 1) When i...

package com.sun.xml.internal.bind.v2.model.annotation does not exist

I'm trying to use a solution for serializing exceptions using jaxb. (http://forums.java.net/jive/thread.jspa?messageID=256122) The class I need to implement for that solution requires referencing the following com.sun classes. import com.sun.xml.internal.bind.v2.model.annotation.AbstractInlineAnnotationReaderImpl; import com.sun.xml.in...

Problem in generating Java classes from XML schema definition using XJC(of JAXB).

I have an XML that looks like this and a corresponding xsd with it. <books> <book name="book1" id="book1"> <name>Harry Potter</name> ........... </book> ........... </books> Please see that 'name' is appearing twice, once as an attribute in tag, and also as an element under tag. Apparently that is invalid syntax, I am no...

Generating a JAXB class that implements an interface

I'm currently using JAXB to generate java classes in order to unmarshall XML. Now I would like to create a new schema very similar to the first and have the classes that are generated implement the same interface. Say for example, I have two schema files which define XML with similar tags: adult.xsd <?xml version="1.0" encoding="UTF-8...

JAXB is good until I need to do something complex. What are the alternatives?

JAXB works well until I need to do something like serialize beans for which I cannot modify the source. If the bean doesn't have a default constructor or if it refers to objects I want to mark transient then I'm stuck writing a separate bean which I can annotate and then manually copy the information over from the other bean. For instan...

Java JAXB XJC code generation form XSD schema problem

Hello I have my own domain model and corresponding XSD schema for it. It consists of data types and messages that are exchanged in my application. I use XJC tool from Java JRE 1.5 for generation of Java classes for the given XSD schema. The generated classes do not contain neither the serialization/deserialization method nor the validat...

JAX-WS client: JAXB required?

Hello! I need to "dive into JAX-WS programming". So, I played around with Netbeans, after 20 or so erroneous attempts, finally managed to let a web service client execute a web service. I noticed, that a lot of code is generated, especially JAXB classes for the web service response. My current task is, to write a web service and web ...

JAXB Jersey annotated classes in a separate jar file on the classpath

I have domain model classes with jaxb annotations in a core jar package. Then I have another service web project that has a dependency on the other core jar, and uses jersey. When I move the domain model classes directly in the services project jaxb correctly finds the annotated classes. When I move them back in the jar, its unable t...

Help with creating a new JAXB instance in Oracle enterprise manager

When trying to create a new JAXB instance inside a servlet I am getting a JAXBException saying the jaxb.properties cannot be found. I have been trying to explicitly pass the classloader with the call to JAXBContext.newInstance() but I cannot figure it out. Here are the class loaders: servlet classloader: oc4j:10.1.3 servlet paren...

javax annotations problem

I freaking loosing my mind on this: I have this code: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ANetApiResponseType", propOrder = { "resultCode", "messages"}) and I get this error: Type mismatch: cannot convert from XmlAccessType to AccessType I've googled , but all these problems usually occur because some...

[JAXB] Set annotation @XMLTransient if id==1

Hi. I have class that represents users. Users are divided into two groups with different id. Could i make something like "if statement", so if (id==1) set annotation on field @XMLTransient Or the only one way to do this is to create two separate classes ? ...

[JAXB] Add XML comments into marshalled file

Hi. I'm marshalling object into xml file. How to add comments into that file? ...

XSD attributes and abstract

I have a hierarchy of Line<--SPLine, Line<--DID_Line Line<--TollFree etc. Then for each line there is a type of action. So I have it looking like this in the xsd: <xsd:complexType name="line" abstract="true"> <xsd:complexContent> <xsd:extension base="tns:executable"> <xsd:sequence> ... ...

JAXB: XML unmarshalling nested objects behaves unexpectedly

Hi, I have a few classes (Class1, Class2, Class3) that I annotated with JAXB annotations (XmlRootElement, XmlElement etc.) to generate XML like this <class1> <field1>ABC</field1> <class2> <c2Field1>XYZ</c2Field1> <class3> <c3Field1>1</c3Field1> </class3> <class3> <c3Field1>2</c3Field1> ...

[JAX-B] How can I ignore a superclass?

I'm trying to write a web service for the java.util.logging api. So I wrote a class MyLogRecord that inherits from LogRecord. I annotated this class with JAX-B annotations, including @XmlAccessorType(XmlAccessType.NONE) so it would ignore non-annotated fields and properties. When I start up tomcat, I get errors that java.util.logging.Lev...

How do I customise jaxb generation?

I have a series of xml messages, all with their own schemas and namespaces. The messages are currently marshalled using JAXB (we still live in a Java 1.4 environment) and we have a large amount of legacy code using this JAXB code so any solution needs to be minimally intrusive. My problem is that while each of the messages has a set of...

Jersey JAXB problem

Hi, I'm trying to use the best practices of rest notes in the following article regarding the connectedness http://www.infoq.com/articles/rest-introduction <order self='customers/1234' > 23 but I can not implement it. if I use the @XmlElement on product object which is an inner object of order class, All of the product f...

JAXB XJC code generation - ObjectFactory class is incomplete

Hello I generate Java classes from my XSD schema file using XJC command line tool. The ObjectFactory class generates incomplete content. It generates creation methods without JAXBElement<Type> createType decoration. What may be the reason of this? Regards Dominik ...