moxy

JAXBException: “package” doesnt contain ObjectFactory.class or jaxb.index

前提是你 提交于 2019-12-05 11:04:40
I have been playing with JAXB / MOXy a lot lately, and it works great on all my tests and example codes . I exclusively using binding files, that's why I'm using MOXy. Please note that in all my examples, I'm NEVER using an ObjectFactory nor a jaxb.index, and it works GREAT . When I get back to my business, I get a nasty JAXB Exception saying that my package does not contain an ObjectFactory or jaxb.index. My project also invovles Spring and Hibernate, JUnit and DBUnit. Here is some sample code: I have an abstract class called AContributionPhysicalSupport. package org.pea.openVillages.pojo

Exception in thread “main” javax.xml.bind.PropertyException: name: eclipselink.media-type value: application/json

こ雲淡風輕ζ 提交于 2019-12-05 10:23:32
问题 I'm attempting to follow the example located here but get an javax.xml.bind.PropertyException. I receive this exception because of the following line of code: marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); I have literally copy/pasted the example listed above so my code is exactly what you see there. Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help. Any help would be most appreciated, (de

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

穿精又带淫゛_ 提交于 2019-12-05 09:15:29
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? EclipseLink JAXB (MOXy) is handling the prefix qualification for elements differently depending upon the attribute form qualification (as demonstrated below).

Jersey 2.0 and Moxy Internal Server Error But No Server Log

隐身守侯 提交于 2019-12-05 02:15:04
I followed the Jersey 2.0 document ( https://jersey.java.net/documentation/latest/user-guide.html#json.moxy ), modified pom.xml, included jersey-media-moxy artifact, compiled and installed. I could get basic POJO to JSON mapping work for both Produces and Consumes cases. However, when I tried with some POJO with complex data type as resource return type, I got a lot Status 500 Internal Server Error but without any server log. It is very annoying. Does anybody know if it is a bug or I missed something in configuration? By the way, in order to use Moxy mapping for a POJO object, the POJO needs

JAXB outputting invalid XML when data contains non-displayable chars

百般思念 提交于 2019-12-04 23:32:03
问题 I'm using JAXB 2.2.5 to output Xml from a JAXB Model, the data is populated from the database and occasionally the database contains non-displayable characters that it should not such as 0x1a If it does then JAXB outputs invalid Xml by just outputting this char as is, shouldn't it escape it or something ? Update I wonder if there are any implementations that do fix this problem, maybe Eclipselink MOXy does ? EDIT I tried the workaround that fixes the illegal char issue however it changes the

Set MOXy as JAXB Provider without properties file in the same package

不想你离开。 提交于 2019-12-04 17:45:24
I am trying to use MOXy as my JAXB provider in order to marshal/unmarshal content into XML/JSON. I have created the "jaxb.properties" file with as content : javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactor Everything works fine. JAXBContext jaxbContext = JAXBContext.newInstance(ServerInformation.class); // The jaxb.properties must be in the same package as "ServerInformation.java" Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType

Jersey + Moxy + JAXB - how to marshal XML without annotations

本小妞迷上赌 提交于 2019-12-04 16:51:09
In http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html about halfway down there's a heading "Customizing the JSON-Binding". How do you similarly customize the XML binding? There seem to be fundamental differences between the way Jersey handles Moxy JSON binding and the XML equivalent. If I follow the instructions in the Jersey documentation for creating a custom JAXBContext resolver to configure Moxy's mapping file, that resolver fires in the JSON case but not in the XML case. See https://bitbucket.org/jmetcher/resttest/ for a very small project demonstrating this. I have

Jersey 2.0 Content-Length not set

我们两清 提交于 2019-12-04 10:32:52
问题 I'm trying to post to a web service that requires the Content-Length header to be set using the following code: // EDIT: added apache connector code ClientConfig clientConfig = new ClientConfig(); ApacheConnector apache = new ApacheConnector(clientConfig); // setup client to log requests and responses and their entities client.register(new LoggingFilter(Logger.getLogger("com.example.app"), true)); Part part = new Part("123"); WebTarget target = client.target("https://api.thing.com/v1.0/thing/

Custom MOXyJsonProvider in Jersey 2 not working?

一曲冷凌霜 提交于 2019-12-04 09:52:30
I was reading over the answer for Moxy ignore invalid fields in json and the approach matched something I'm trying to do, so I decided to give it a shot.. I created a feature to disable the default ConfigurableMoxyJsonProvider; @Provider public class JsonFeature implements Feature { @Override public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase(); context.property(disableMoxy, true); return true; } } And I created a really simple custom provider;

How to set namespace aware to false?

只愿长相守 提交于 2019-12-04 06:56:31
I'm trying to parse some XML with EclipseLink MOXy, and it's failing on the line with the xsi attribute. If I remove this, it parses fine. However, I've got 100GiB of XML to wade through and changing the source files is not an option. It's been suggested that if I can set XmlParser.setNamespaceAware(false) then it should work - but I've got no idea how to configure this, without breaking right into the guts of MOXy. <record> <header> <!-- citation-id: 14404534; type: journal_article; --> <identifier>info:doi/10.1007/s10973-004-0435-2</identifier> <datestamp>2009-04-28</datestamp> <setSpec>J<