I met a problem when JAXB unmarshalling xml data.
JAXB throws exception when unmarshalling empty value for int, double or date attribute from xml. For example, it throws java.lang.NumberFormatException when it unmarshals the following xml data.
<sku displayName="iphone" price=""/>
The following is my schema.
<?xml version="1.0" enco...
I have to design a data model (in a Java EE 6 application) that will be persisted via JPA, and that also needs to be serialized via JAXB. The last time I did that, I had one group of entity classes with JAXB annotations, and another with JPA annotations. This meant that I had to have a lot of boilerplate code for translating between the ...
I'm using JAXB in a web service with some slightly complex objects. One of the objects, Sensor, has a list of other objects it can communicate with, which necessarily can include itself (behavior that cannot be changed), leading to a cyclic reference during marshalling to XML.
@XmlAccessorType(XmlAccessType.FIELD)
public class Sensor e...
There's ugly XML file that has to be unmarshalled:
<?xml version="1.0" ?>
<configuration>
<section name="default_options">
<value name="default_port">8081</value>
<value name="log_level">WARNING</value>
</section>
<section name="custom_options">
<value name="memory">64M</value>
<value name="co...
I have an object, generated by XJC, called Product. I want to set product.currentPrice (a String) to be &#x00A3;210 where &#x00A3; is the currency symbol (passed in from elsewhere in the system).
Trouble is, JAXB is escaping my ampersand, so it produces &amp;#x00A3;210 instead. How do I make it not do this?
...
[Heavily edited as understanding progresses]
Is it possible to get Spring Jaxb2Marshaller to use a custom set of namespace prefixes (or at least respect the ones given in the schema file/annotations) without having to use an extension of a NamespacePrefixMapper?
The idea is to have a class with a "has a" relationship to another class t...
I have never used JAXB before. I am working on a test harnesses project. I have around 20 different testcases. when i run my test i get this error.
my structure is like
A is the bestTestCase class.
B extends A.
C extends B.
Base Class A:
public Class A {
public A(String t){
testName = t;
}
private String aData;
privat...
I am using Jersey and JAXB to build a simple RESTful webservice
I have a HashMap of 'String' to 'Integer':
2010-04 -> 24
2010-05 -> 45
I need to generate an XML response which looks like this:
<map>
<2010-04>24</2010-04>
<2010-05>45</2010-05>
</map>
What is the best way to generate dynamic tag names with JAXB?
...
I'm having trouble getting Jackson to correctly deserialize json into an object when calling a service (specifically we're using Jackson's ability to use JAXB annotations since we also want the service to use XML). I'm using Spring MVC and I'm using the RestTemplate class to make calls to the service.
Here is where I setup the MappingJ...
I have a pretty large set of Java classes, many that stem from each other. I want to know how to specify in the java code (with an annotation) when a certain property of a class is limited. For example, a vehicle.java class should only be able to have 1 manufacturer and 2-4 wheels.
I have come across minOccurs and maxOccurs in generate...
Hello, I am having issues deploying my Jersey RESTful web service to weblogic 9.2
I followed a tutorial at http://www.vogella.de/articles/REST/article.html.
The tutorial is for java 6 and tomcat 6 which it works fine for. However, I need to convert this to java 5 and tomcat 5.5 so that I can successfully deploy it on weblogic which use...
I have a JAX-RS webservice that makes use of JPA entity classes. I have a resource class like this:
@Path("/entity")
public class MyEntityResource
{
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/{entity}")
public MyEntity getMyEntity(@PathParam("entity") String entity)
{
log.debug("Entering getMyEntity w...
I would like to know how I can make the JAXB compiler make certain elements in my XML schema be declared as final in the java class definition and I would also like to be able to control the different constructors, as in I would like a constructor that could create the object with a full list of parameters contained in the class as well ...
In one of my projects I use JAXB2 marshaller, having a contract-first web service I generate the objects from a XML Schema.
Everything works just fine. But, I have a "code usability" issue. Let me give you an example.
Schema:
<xs:complexType name="personContractAlertListType">
<xs:sequence>
<xs:element ref="PersonContrac...
We are building a webservice which consumes and produces JSON.
Problem:
We are kind of confused about how to represent some specific details of a object.
Example: we specify any empty element or null element as null in JSON
The question we ask our self is how do we represent a object when its properties are all null.
example: car is...
Is it possible to use the shemagen ant Task to generate an xsd schema from class files instead of from source?
...
I wrote some Java classes and annotated them with the JAXB annotations.
After that I used schemagen to generate an xsd.
Then I build an object graph and marshalled it to a xml file.
I modified the xml file so that it was not valid anymore.
I wanted to use the xsd in the hope the JAXB unmarshalling fails. But it doesn't. Why?
JAXB is ...
Using Spring 3, I have created a MarshallingView, with the following marshaller:
<bean name="xmlMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
<property name="classesToBeBound">
<list>
<value>com.mydomain.xml.schema.Products</value>
</list>
</property>
<property name="marshalle...
How to create a JAXB java class out of a xml schema using a utility?
I don't like reverse-engineering of several huge XSD-files to a JAXB-compliant java class.
I know there's the jdk utility schemagen - but this works the other way round.
What tool can help me?
...
I have the following entity structure (A, B, C, D are entities):
A-> one-to-many B,
A-> one-to-many C,
B-> one-to-many D,
C-> one-to-many D.
I want to persist entity A with hibernate but I am sending it over web service (cyclic references are eliminated). So, on the server I receive parents that “know” about the children and childre...