jaxb2

Injecting Jaxb2Marshaller in Spring MVC controller

拜拜、爱过 提交于 2019-12-10 16:16:47
问题 I am trying to convert a static xml into a POJO (unmarshalling) in my controller class. I am using Jaxb2Marshaller and I am configuring in the following way in my root context <oxm:jaxb2-marshaller id="marshaller"> <oxm:class-to-be-bound name="org.springframework.ws.samples.airline.schema.Airport"/> </oxm:jaxb2-marshaller> I am trying to inject the marshaller using autowiring. But it throws No Bean Found Exception . @AutoWired private Unmarshaller marshaller; How to inject the marshaller in

How to set Jaxb2Marshaller list of XmlAdapters in Spring bean through XML?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 13:27:11
问题 I'm trying to define a Jaxb2Marshaller bean in Spring-WS to use a custom adapter that extends XmlAdapter . I have the following in an XML file: <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <!-- various classes to be bound... --> </list> </property> <property name="schema" value="myschema.xsd" /> <property name="adapters"> <list> <value>com.lmig.am.claims.clip.ContactAdapter</value> </list> </property> </bean>

Jaxb namespaces for java.util.Map properties

不问归期 提交于 2019-12-10 10:23:56
问题 I have a simple class that contains a hashmap: @XmlRootElement() public class Customer { private long id; private String name; private Map<String, String> attributes; public Map<String, String> getAttributes() { return attributes; } public void setAttributes(Map<String, String> attributes) { this.attributes = attributes; } @XmlAttribute public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) {

JAXB - marshalling with recursive dependency

眉间皱痕 提交于 2019-12-08 09:15:44
is anybody try to marshal JAXB object with recurisive referency? I have following class: public class A { private Long id; private String name; private List<A> aList; } and I'd like to marshall it to: <a> <a> <a>...</a> ... </a> ... </a> I'm using maven plugin to auto generate JAXB class from XSD. Any suggestions? Below is how you can support this use case starting from your XML schema. XML SCHEMA (schema.xsd) The following XML schema is based on the comment you made to a previous answer (http://stackoverflow.com/a/14317461/383861). <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs=

How to generate JAXB classes in Eclipse using additional JAXB plugins

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 06:36:15
问题 I am using Eclipse LUNA to generate JAXB Classes. I am attempting to employ the jaxb2-annotate-plugin to add arbitrary annotations to my schema-derived classes. My restrictions are that I cannot change the related xsd's and I don't want to amend the generated classes. how do I activate jaxb2 when generating JAXB classes from within Eclipse? All I need to do is perform the equivalent of using the @XmlType.namespace annotation. I am right clicking on my xsd file, selecting Generate > JAXB

JAXB - marshalling with recursive dependency

筅森魡賤 提交于 2019-12-08 04:46:49
问题 is anybody try to marshal JAXB object with recurisive referency? I have following class: public class A { private Long id; private String name; private List<A> aList; } and I'd like to marshall it to: <a> <a> <a>...</a> ... </a> ... </a> I'm using maven plugin to auto generate JAXB class from XSD. Any suggestions? 回答1: Below is how you can support this use case starting from your XML schema. XML SCHEMA (schema.xsd) The following XML schema is based on the comment you made to a previous answer

packagename doesnt contain ObjectFactory.class or jaxb.index

Deadly 提交于 2019-12-07 22:56:12
问题 While deploying my project to a tomcat-server, I get constantly this exception: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller': Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: "be.icredit.einvoice.proxy.customerdaoservice" doesnt contain ObjectFactory.class or jaxb.index But it does have an

JAXB Unmarshalling an subset of Unknown XML content

孤街浪徒 提交于 2019-12-07 15:08:42
问题 I have a requirement to unmarshall a subset of Unknown XML content, with that unmarshalled object, I need modify some contents and re-bind the same XML content(subset) with the Original XML. Sample Input XML: <Message> <x> </x> <y> </y> <z> </z> <!-- Need to unmarshall this content to "Content" - java Object --> <Content> <Name>Robin</Name> <Role>SM</Role> <Status>Active</Status> </Content> ..... </Message> Need to unmarshall the <Content> tag alone, by keeping the other XML part as same.

Spring 3, ReST, @ResponseBody and @ExceptionHandler

怎甘沉沦 提交于 2019-12-07 06:08:48
问题 I have been trying to get exception handling working in my simple Spring 3 based ReST web services. Based on everything I have seen, there is a bug that prevents this from working automatically with the @ResponseBody and @ExceptionHandler annotations https://jira.springsource.org/browse/SPR-6902 So given that it isn't supported until Spring 3.1 or 3.0.6, what is the current best method for doing exception handling? I have seen numerous posts but haven't found a clear answer that has worked

JAXB: Qualified attributes disables default namespace xmlns=“”?

拈花ヽ惹草 提交于 2019-12-07 05:51:56
问题 When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, ...) or @XmlAttribute(namespace = "sample.com/y", ...) JAXB ignores @XmlSchema(namespace = "sample.com/x", ...) and instead of: <a xmlns="sample.com/y" xmlns:ns0="sample.com/y"> <b ns0:att=""/> </a> generates something like: <ns1:a xmlns:ns1="sample.com/x" xmlns:ns0="sample.com/y"> <ns1:b ns0:att=""/> </ns1:a> Is this an expected behavior? Is there any way to correct this? 回答1: EclipseLink JAXB (MOXy) is handling the prefix