jaxb2

Unhandled exception on trying to create JAXBContext (Jaxb 2.0)

Hi, I am trying to get the code past this line: JAXBContext jaxbContext = JAXBContext.newInstance("foo.bar.package"); It throws an exception - heres the stack trace - any ideas folks? SEVERE: Unhandled exception or error intercepted java.lang.NoClassDefFoundError: javax/activation/DataSource at com.sun.xml.bind.v2.model.impl.Runtime...

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 -...

What is the Jaxb equivalent of a CData Block?

I am looking to convert a class that looks like this ... public class Amenity { public String id; public String value; } into the following XML using JaxB annotations: <amenity id="id-string-here">value-string-here</amenity> Does anyone know what annotation to use on the value member variable to accomplish this? The closest I...

JAXB appending unneeded namespace declarations to tags

I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:i...

How to use jaxb 2 in a web application within Oracle Application Server

I have an application that is running Jaxb 2.1.12. I am running JDK 1.5 and OC4J 10.1.3.4.0. When I try to use the portion of my application that is using Jaxb, I get the following error: Unable to locate jaxb.properties for package I narrowed this down to the xml.jar that comes with OC4J. It contains Jaxb 1.0 classes. I can fix this ...

Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?

For example, I've got a simple schema which imports another schema. The second schema (urn:just:attributes, just-attributes.xsd) just defines an attribute group. <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/MySchema" xmlns:tns="http://www.exampl...

JAXB 2.0 - How to skip processing of nodes and return them as a String

Hello, I am processing XML documents with JAXB 2.0 where I need information(in my example 'id') mapped to Java objects and run some business logic with. Everything works fine here. But these XML documents always hold a collection of approximately 500 nodes that I just want to save to a database in the original xml format, so I am jus...

JAXB lists namespaces in root element (-> each element)

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: Is there a way to describe namespace in each element instead of root element ?: It also solves the problem of "unnecessary namespaces", which is also important in my case. Any suggestions appreciated. ...

jaxb namespaces in each element instead of root element during marshalling

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: <rootElement xmlns="default_ns" xmlns:ns1="ns1" xmlns:ns2="ns2"> <ns1:element/> </rootElement> Is there a way to describe namespace in each element instead of root element ?: <rootElement xmlns="default_ns"> <...

Java libraries for converting xsd to bean/objects

What are my options for libraries to convert XSD files to java beans or objects? I have a large XSD that I have been trying to convert using JAXB2, but JAXB2 is creating invalid classes. ...

Is it possible the generate shared objects using JAXB?

I have 3 xsd files: a.xsd b.xsd shared.xsd shared.xsd is imported to both a.xsd and b.xsd using <xs:import schemaLocation="shared.xsd"/> shared.xsd defines <xs:element name="item"> <xs:complexType> .... If I generate java code using xjc a.xsd and b.xsd is generated into different packages and in each package a separate java c...

xslt help - remove empty tags and replaces * with empty tags

Hi, I am having a problem while doing some XSLT pre-processing in my java program. We get an asterisk (*) from a mainframe program when it wants to blank out a value, which my java process has to treat like a blank or empty tag. So we apply an xslt to the input before my jaxb process. We are applying this xslt : <xsl:stylesheet vers...

Spring web service: easy way to un-marshall a bean to XML client side?

I am utilizing spring to do all of the marshalling/unmarshalling of my bean objects (via jaxb2Marshaller/WebServiceTemplate). For debugging purposes, I would like to be able to spit out the request/response XML. Does anyone know if this is possible? Thanks. ...

Jaxb 2 mapping different element to the same property

I wonder if this is possible in jaxb2. I have a xml that can be either < element > or < element2 > it will never apear at the some time. They are both of type String and I want it to map to the same property in my java class. Is there a way in jaxb2 to configure that? Thanks Charlie ...

Problem implementing GET REST service due to JAXBException: IllegalAnnotationExceptions

I am having a really strange problem implementing Java REST service. I am trying receive the following model: @Data @EqualsAndHashCode(callSuper=false, of={"primaryKey"}) @Entity @Table(name = "T_UNIQUE_IDENT_TYPE") @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @XmlRootElement(name="UniqueIdentifierType") @XmlAccessorType...

How to create a jaxb.index file on the fly using Ant (or Maven)

Hi, This is more of knowledge sharing rather than asking a question. Thought this little Ant snippet might be useful to someone. <target name="create-jaxb-index" depends="compile"> <!-- Create a suitable jaxb.index file on the fly to remove the need for an ObjectFactory jaxb.index is a simple list of the domain objects wit...

Can I customize JAXB @XmlElementWrapper elements for a java.util.Map

Hi, I'm trying to learn to use Map with Jaxb. I did this: @XmlElementWrapper(name = "phoneNumbers", nillable = true) private Map<String, PhoneNumber> phoneNumbers; and the result was: <xs:element nillable="true" name="phoneNumbers"> <xs:complexType> <xs:sequence> <xs:element name="entry" minOccurs="0" maxOccurs="un...

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...

InstantiationException in web service client calling Web Service deployed to JBoss.

I'm deploying a StatelessSessionBean annotated with @WebService to JBoss. I'm taking the WSDL generated by JBoss to generate client stubs. My problem is in calling a method which returns a list of objects. If the list is empty the call succeeds however if the list is not empty then I get the following exception: com.sun.xml.ws.encoding....

Marshall abstract class without its type definition

I try to achive the opposite of here. I have an abstract class, but I do not want the abstract class' type and tag to be outputted. So I need an output, which basically looks like <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <dokument ausgabe="ausgabe_test.doc" vorlage="vorlage_test.dot"> <marke typ="text" name="test"> ...