jaxb

JAXB, how to marshal without a namespace

I have a fairly large repetitive XML to create using JAXB. Storing the whole object in the memory then do the marshaling takes too much memory. Essentially, my XML looks like this: <Store> <item /> <item /> <item /> ..... </Store> Currently my solution to the problem is to "hard code" the root tag to an output stream, and marsha...

Where should you put XSD documentation in order for JAXB to pick them up and put them in Javadoc?

I am developing a contract first webservice and wish to include the appropriate documentation in the schema so that it is as self descriptive as possible. What is the best practice to put XSD annotations and documentation such that JAXB picks them up and includes them in the generated Java files as Javadoc? I noticed that some elements ...

JAXB + JAK java.lang.ClassCastException

Hi, I read page about JAK implementation where is a piece of code from pom.xml file (Listing 1). This piece of code is actually commented in pom.xml file so i uncommented it in order to add my own schema to compile. After that i run command mvn -e clean install, and i get this error: ivansek ~/Sites/Xlab/KMLTest/javaapiforkml-read-only...

How do I marshal java.util.List with JAXB like JAX-RS (CXF, and Jersey) do.

It seems the latest JAX-RS can handle methods returning java.util.List as the XMLRootElement but normal JAXB cannot. I would like to mimic what CXF and Jersey are doing. In other words I would like to Marshal a List and just like CXF and Jersey do. Normally if you try to marshal a list with JAXB you get the Root Element exception. How d...

JAXB - How to add xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

I am using JAXB to create XML file from a result set. I have created java/ /class files using the xsd with the help of xjc utiliy. Now I am trying to create the xml file using the Marshaller. In the XML file I do not see the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attribute with the root tag. public class JAXBConstructor ...

How can i tell jaxb / Maven to genereate multiple schema packages?

Example: </plugin> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.7.1</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </ex...

JAXB - ClassNotFoundException: com.sun.xml.bind.ContextFactory_1_0_1

I am getting error : GC 16192K->1983K(260160K), 0.0101954 secs] avax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory_1_0_1 not - with linked exception: java.lang.ClassNotFoundException: com.sun.xml.bind.ContextFactory_1_0_1] at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:152) at javax.xml.b...

avoid the use of 'mixed=true' in xml schema

I am using xjc to convert a schema to java classes. When I am using mixed=true in the schema I am losing the access method for child nodes instead there is a single general content access method. Is there a way to rewrite the schema without using mixed=true. There is no way that I can change the xml so I have to customize the schema. S...

In generated code, how to access the facets declared in the XSD file ?

Hi, What I thought was going to be a simple problem turns out to be quite a head scratcher. I am currently using JAXB 2 to generate code from an XSD on which I have no control. I need to access the constraints from the schemas so I can apply some logic and guard code when setting values in these objects. Validation in bulk simply will...

Question on XJB

I have two tables -- INSTALL_BUILD_RESULTS and BUILD_RESULTS. IBR has a primary key called Install_Build_Id and BR has a primary key called Build_Id. Both are numbers A third table, LINK_BUILD_TO_INSTALL_BUILD is a table simply consisting of the two columns mentioned above, used together as a composite key. How can I write an xjb for ...

Java xml binding with wrong xmlns attribute name

When I use the annotation: @XmlRootElement(name="RootElement", namespace="namespace") class RootElement { to create xml file from java, it creates the root element as: <ns2:RootElement xmlns:ns2="namespace"> but I wanted to create without the "ns2", like: <RootElement xmlns="namespace"> Any idea how to fix it? Reletad link (exa...

Does XSD allow simpleContent and complexContent at the same time?

I want to write an xsd for the xmlrpc spec (and generate java classes out of it using jaxb). The xmlrpc spec allows values like: <value><int>123</int></value> <value><boolean>1</boolean></value> But at the same time it requires: If no type is indicated, the type is string. Which means i could receive something like this: <value...

NoSuchMethodError: com/sun/istack/logging/Logger.getLogger

I developed a webservice and deployed it to websphere 7.0 and developed a dynamic dispatch client using JAX-WS APIs which also runs on same application server. I get error at the following line: Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); Error: Caused by: java.lang.NoSuchMethodError: c...

JAXB problem with "com.xyz.ReadSomething nor any of its super class is known to this context."

Hi, I get this exception (written in the title) when trying to call a webservice. The road so far was, I generated a bunch of classes for the objects, service and service methods via wsimport and if I only use the generated objects calling the service works. The problem is that wsimport also generates classes which already exist as ...

how to remove empty tags in input xml

My java module gets a huge input xml from a mainframe. Unfortunately, the mainframe is unable to skip optional elements, with the result that I get a LOT of empty tags in my input : So, <SSN>111111111</SSN> <Employment> <Current> <Address> <line1/> <line2/> <line3/> <city/> <state/> <country/> </Address> <Phone> <phonenumber/> <countr...

Create Hello World with RESTful web service and Jersey

I follow tutorial here on how to create web service using RESTful web service and Jersey and I get kind of stuck. The code is from HelloWorld3 in the tutorial I linked above. Here is the code. I use Netbean6.8 + glassfish v3 RESTGreeting.java create using JAXB. This class represents the HTML message in Java package com.sun.rest; im...

Is it a jaxb bug?

I take a scheme, its element definition as follows: <xs:complexType name="OriginalMessageContents1"> <xs:sequence> <xs:any namespace="##any" processContents="skip"/> <xs:any namespace="##any" processContents="skip" minOccurs="0"/> </xs:sequence> </xs:complexType> I use xjb to export java file,xjb as follow: <j...

Is JAXB Bug? please help me

I take a schema, its element definition as follow: <xs:complexType name="OriginalMessageContents1"> <xs:sequence> <xs:any namespace="##any" processContents="skip"/> <xs:any namespace="##any" processContents="skip" minOccurs="0"/> </xs:sequence> </xs:complexType> I use xjb to export java file,xjb as follow: <jx...

jaxb XmlAccessType: PROPERTY example

I'm trying to use jaxb and want to use the 'XmlAccessType.PROPERTY' to let jaxb use getters/setters rather than variable directly, but get different errors depending on what I try, or the variable isn't set at all like I want. Any good link or pointer to a simple example? For example, the below makes the groupDefintion not to be set w...

Does JAXB work under Java 5?

Building with maven I get "package javax.xml.bind.annotation does not exist" What do I need to make JAXB work with Java 5? ...