jaxb

Jaxb marshaller ang generics(2)

there are types: class A{} @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) @XmlType(propOrder = {"obj"}) @XmlRootElement(name = "response") public class B<T extends A> extends A{ private T obj; @XmlElement(required = true) public T getObj() { return obj; } } When i'm trying to marshal this i get an error: org.springframew...

Using JAXB inside a Confluence Plugin

I have a Confluence plugin I am working on that contains a series of classes that use JAXB. When the plugin runs I get the following runtime-exception: [INFO] [talledLocalContainer] javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found [INFO] [talledLocalContainer] - with linked exception: [INFO] [talledL...

JAXBContext.newInstance memory leak

After a recent deployment in system test, one of our servlets was getting hit much harder than usual and we noticed memory started climbing and weblogic would eventually die. My intern, I was very proud, discovered the source of the memory leak. Whenever a request comes in, this line gets called: JAXBContext jc = JAXBContext.newInstanc...

jaxb SAXParseException: Relative URI "./dtd/my.dtd"; can not be resolved without a document URI

Java journeyman but Web service noob I have a class that unmarshals xml from a 3rd party source (I have no control over the content). Here is the snippet that unmarshals: JAXBContext jContext = JAXBContext.newInstance("com.optimumlightpath.it.aspenoss.xsd"); Unmarshaller unmarshaller = jContext.createUnmarshaller() ; StringReader xmlS...

JAXBContext and Marshaller change the order of XML namespace

I have a code line like this : StringWriter writer = new StringWriter(); JAXBContext jc = JAXBContext.newInstance(namespace); Marshaller marshaller = jc.createMarshaller(); marshaller.marshal(input, writer); When namespace = "nfpa:nfpares". I have a generated content like this : <?xml version="1.0" encoding="UTF-8" standal...

How to handle Enum with Generics in JAXB?

JAXB runtime is failing to create JAXBContext for a Class whose member variable is defined as @XmlElement(name = "EnumeraatioArvo") private Enum<?> eenum; How to handle such scenario in JAXB? ...

Generating java classes from xsd files

Hi, I have got a xsd files from some thirdparty which used to be with "include" and not "import". I am using these xsd file to generate java files, using jaxb. The initial xsd structure resulted in output in which same classe were included in different packages. for example, if two packages were generated, "aa" and "bb", both included th...

How to customize namespace prefixes on Jersey(JAX-WS)

Hi, when serializing my resources on Jersey, I want to use namespaces in some cases. Is there any way to customize the namespace prefixes on jersey? Default: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <order xmlns:ns2="http://www.w3.org/2005/Atom"> <price>123</price> <ns2:link rel="duh" href="/abc/123"/> <ns2:l...

Dynamically adding types to a jaxb context.

Hi, I have multiple plug-ins in my RCP-based project. I want to be able to define @XMLElements in one plug-in that can then be marshaled / un-marshaled from the core plugin. To do so, I report the classes that are serializable as soon as the plug-in is loaded. However, dynamically adding classes seems to be not supported by the JAXBCont...

How to execute the JAXB compiler from ANT

Hi, I am using JAXB on a project. the attraction of JAXB is that it is bundled with the JDK, I have been to use xjc.exe on the command line to generate the .java files from a schema. I can't seem to find the JAXB ant task, sure there is a download at https://jaxb.dev.java.net however i want to use the JAXB that is bundled into the JDK i...

looking for link to runtime complexity and/or benchmarks table for JAXB

Hi all, I think the title should be pretty clear, but: I am looking to determine what kind of performance I can expect from a software component that is running JAXB--both for marshal and un-marshal operations. I'd hoped to find a page of benchmarks, or some sort of white paper that spoke about complexity, but my web searches haven't tu...

Within CXF, why use any other binding than JAXB? (MTOM attachments, Aegis, XMLBeans,...)

I have been playing around with Apache CXF, in particular the various data bindings it supports: JAXB (the default), MTOM, Aegis and XMLBeans. Since all of these are supported, I suppose each has its merits. I came up with these: Obviously, MTOM is to be preferred where large attachments are involved. JAXB depends on annotations, so it...

Add xmlns="" in the xml

I am getting response XML, in that I want to add xmlns attribute in each child node which is generated. Present output: <createProfileResponse xmlns="http://services.profile.webservices.ecaas.com"&gt; <createProfileReturn>STRING</createProfileReturn> </createProfileResponse> Required output: <createProfileResponse xmlns="http:/...

XSD Formatting <element><complexType> vs <complexType/><element/>

This XSD portion was obtained from: http://www.iana.org/assignments/xml-registry/schema/netconf.xsd <xs:complexType name="rpcType"> <xs:sequence> <xs:element ref="rpcOperation"/> </xs:sequence> <xs:attribute name="message-id" type="messageIdType" use="required"/> <xs:anyAttribute processContents="lax"/> </xs:complexTy...

JAXB: setting complexTypes to use existing java classes.

Currently, JAXB is creating a point class from the xml schema I have specified. However, I would prefer it to use the existing java.awt.Point class. And for any other types I have defined to use and import java.awt.Point too. Here is my point code: <xs:complexType name="point"> <xs:sequence> <xs:element name="x" type="xs:int" /> ...

Scala: jaxb or similar?

As a java programmer I'm quite comfortable with using JAXB and similar, for example to construct object from a XML spec. I'm sure I can make JAXB work nice in scala, but I wonder if that is the scala way of doing it, or if there is some better/smarter way, especially since XML is almost part of the language / it's internal libraries. S...

Why does JAXB sometimes map to JAXBElement?

There is a placeholder answer over at the unofficial guide with a link to an article which (to me) seems quite unrelated. I use XJC to generate my JAXB classes and while most of them map to each other as expected, some elements get mapped to JAXBElement<Foo>. This is most annoying for graphs with cycles, where sometimes the parent node ...

jaxb - generate classes from single schema in different packages depending on namespace

My requirement is that I have a very big schema and it has many different tags with different namespaces. I want to generate classes from that schema into different packages and I want this thing to be bases on namespace i.e. I want classes corresponding to tags in one namespace to be in one package and classes corresponding to tags in o...

how can I add xml attributes to jaxb annotaded class XmlElementWrapper

I have a class with a XmlElementWrapper annotation like: ... @XmlElementWrapper(name="myList") @XmlElements({ @XmlElement(name="myElement") } ) private List<SomeType> someList = new LinkedList(); ... This code produces XML like <myList> <myElement> </myElement> <myElement> </myElement> <myElement> </myElemen...

REST and JAVA JPA

I am trying to understand the code of some project which is not properly documented.Am the only developer working on the task.I dont have much experience. There is a data model and there are some classes witten to access it.It was mentioned that the data model has some rest api on top of it.But when i see the code i can see getter cod...