jaxb

How do I prevent JAXB from binding superclass methods of the @XmlRootElement when marshalling?

I have a class that is annotated as the @XmlRootElement with @XmlAccessorType(XmlAccessType.NONE). The problem that I am having is that the superclass's methods are being bound, when I do not want them to be bound, and cannot update the class. I am hoping there is an annotation that I can put on the root element class to prevent this f...

Saving a XML-Document in a Database (Combination of Hibernate and JAXB) in Java

I am looking for a solution to save a XML-File in a database using Hibernate. The problem is, that the structure of the XML-file is different to the Hibernate-beans. I'm trying to use JAXB to serialize the XML-content to the Hibernate beans. Please imagine the following scenario: There is this xml file: <root> <general> ...

Why does JAXB 2.0 with jdk1.5 fail to recognize string enumerations that start with a numeral?

Following is the sample schema I used to try to generate the JAXB classes. What I noticed is that when I have a string type with enumerations, for instance, in my case the stepType, with values starting with a numeral, JAXB does not generate a separate enum class say StepType class. It works fine, when I use only alphabets for the valu...

Role based or shopping cart style Java bean binding?

I have a POJO that I would like to expose as XML from a web service, preferably with JAX-B. The fields that need to be exposed in XML depend on what type of user is making the request. For instance, we have a role for HumanResources and Finance users. A User might be defined as: @XmlRootElement public class User { @XmlElement public ...

Class Cast Exception when trying to unmarshall xml?

Hi, 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 generated by the xjc.bat tool - and the classes it generated I have not altered at all -...

LinkageError JAXB 2.0 -> 2.1 (Tomcat)

I'm getting this error when trying to access my webservice running inside tomcat. Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstr ap classloader, but this RI (from jar:file:/C:/software/tomcat6/webapps/messagin g/WEB-INF/lib/jaxb-impl-2.1.5.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.c lass) needs 2...

Jaxb equivalent in C#

Using JAXB in Java it is easy to generate from a xml schema file a set of Java classes that xml conforming to that schema can be deserialized to. Is there some C# equivalent of JAXB? I know that Linq can serialize and deserialize classes to/from xml files. But how can I generate C# classes from xml schema file and then use this classes ...

java JAXB and inheritance

I want to create a list different types of class, which are all inheritance from the same superClass. I am starting from an xsd file and I want to create the java classes and in run time load xml file that has a list nodes. My problem is define the xsd that will create the java classes. I am using JAXB 2.0 eclipse plugin. In the end I ...

How can I extend Java code generated by JAXB, CXF or Hibernate tools?

With generated Java source code, like code generated with Hibernate tools code generated with JAXB schema binding (xjc) code generated with WDSL2Java (cxf) all generated classes are "value object" types, without business logic. And if I add methods to the generated source code, I will loose these methods if I repeat the source code g...

Elements of anonymous complexTypes

Hi all! I try to generate classes for schema that contain 2 elements of anonymous complexTypes: <xsd:element name="elementOfAnonymousComplexType1"> <xsd:complexType> <xsd:simpleContent> <xsd:restriction base="xsd:string"> </xsd:restriction> </xsd:simpleContent> </xsd:complexType> </xsd:el...

JAXB Types problem

I have an xsd that looks like this (snippet): <xs:complexType name="IDType"> <xs:choice minOccurs="1" maxOccurs="2"> <xs:element name="FileID" minOccurs="0" maxOccurs="1" type="an..35" /> <xs:element name="IDNumber1" minOccurs="0" maxOccurs="1" type="an..35" /> <xs:element name="Number" minOccurs="0" maxOccurs="1" ty...

JAXBContext initialization speedup?

Is there any way to speed up the initialization of javax.xml.bind.JAXBContexts with a large (>1000) number of classes? In our XML heavy application the startup time is some 10 minutes and consists mainly of the initialization time of the JAXBContexts. :-( We are using Sun's JAXB implementation in the JDK 1.5 and the org.jvnet.jaxb2.mave...

Can one validate marshalled XML with JAXB 2.0?

Apparently in version 2 of JAXB - the validator class has been deprecated - does this mean the marshaller is automatically validating your XML? If so it doesn't seem to be complaining about some of the incorrect XML I am forming! Can anyone give me some advice on how I can validate marshalled XML to make sure it conforms to the XSD sch...

JAXB: How should I marshal complex nested data structures?

Hello! I have several complex data structures like Map< A, Set< B > > Set< Map< A, B > > Set< Map< A, Set< B > > > Map< A, Map< B, Set< C > > > and so on (more complex data structures) Note: In my case it doesn't really matter if I use Set or List. Now I know that JAXB let me define XmlAdapter's, that's fine, but I don't want to def...

No @XmlRootElement generated by JAXB

I'm trying to generate Java classes from the FpML (Finanial Products Markup Language) version 4.5. A ton of code is generated, but I cannot use it. Trying to serialize a simple document I get this: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: unable to marshal type "org.fpml._2008.fpm...

JAXB Marshalling and Generics

I am trying to use JAXB's introspection to marshall and unmashall some existing domain objects marked up with JAXB annotations. Most things work as expected, but I am having quite a bit of trouble getting a fairly simple class to serialize. This class is used as an @XmlElement on a number of beans and looks something like: public class ...

Using JAXB to unmarshall elements with varying/dynamic names

I'm parsing an XML document that has nodes like the following: <objects> <dog> <data1>...</data1> <data2>...</data2> <data3>...</data3> </dog> <cat> <data1>...</data1> <data2>...</data2> <data3>...</data3> </cat> </objects> The elements data1, data2, data3 are always consistent. Only the parent tag vari...

JAXB Marshalling with null fields.

Hello, This is a pretty simple request, but I just didn't find a way to do it. I'm basically trying to set up a role in JAXB which says that whenever an null field is encountered, instead of ignoring it in the output, set it to an empty value. So for the class : @XMLRootElement Class Foo { Integer num; Date date; …. } When thi...

How to handle rpc/literal webservice with JAXB2 and Spring-WS

We need to access a legacy webservice that uses the RPC/literal webservice style and also to provide webservice endpoints for it. If you use webservices of document/literal style with Spring WebserviceTemplates / WebserviceEndpoints, you can use JAXB2 to generate / marshal / unmarshal the webservice requests. But how do you do this with...

xjc binding customization does not work in jaxb 2.1.3. It works in jaxb 2.0

I developed a binding customization file in jaxb 2.0 in JDK 1.6.0 and it worked fine. Now I'm using jaxb 2.1.3 in JDK 1.6.0_13 and it gives me errors: Error xxx shows up in more than one properties which is what the binding file is suppose to be handling by renaming them. What happened between 2.0 and 2.1.3 that I need be aware of and...