Comments (3)
- The correct name of the property is "org.glassfish.jaxb.namespacePrefixMapper".
- This property is exclusive for marshalling. You can not use at unmarshalling process.
Regards,
Antonio.
from jaxb-ri.
@antoniosanct Thanks a lot for the response. For your convience I have added the sample code repo here: https://github.com/Aravinda93/test/tree/main
I was trying couple of things thats the reason I added the org.glassfish.jaxb.runtime.marshaller.NamespacePrefixMapper
but I have tried the org.glassfish.jaxb.namespacePrefixMapper
and that did not work either for me.
As you mentioned I have removed the Unmarshaller
part although I was not using it and kept only the Marshaller
but still I get the same error:
Exception in thread "main" jakarta.xml.bind.JAXBException: property "org.glassfish.jaxb.namespacePrefixMapper" is not supported
Following is my main class updated:
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
import java.util.HashMap;
import java.util.Map;
public class MainXML {
public static void main(String[] args) throws Exception {
final Map<String, String> myNamespaces = new HashMap<>();
myNamespaces.put("test", "https://test.com");
myNamespaces.put("test2", "https://test2.com");
final JAXBContext jaxbContext = JAXBContext.newInstance("io.test.convert", Thread.currentThread().getContextClassLoader(),
new HashMap<>() {
{
put(
"org.glassfish.jaxb.namespacePrefixMapper",
new CustomNamespacePrefixMapper());
}
});
//final JAXBContext jaxbContext = JAXBContext.newInstance("io.test.convert", Thread.currentThread().getContextClassLoader());
final Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty("org.glassfish.jaxb.namespacePrefixMapper", new CustomNamespacePrefixMapper());
final Child1 child1 = new Child1();
child1.setName("Batman");
child1.setAge("30");
child1.setType("Superhero");
child1.setOriginalName("Bruce Wayne");
marshaller.marshal(child1, System.out);
}
}
from jaxb-ri.
@Aravinda93
You can not set this property at context initialization. See constants defined here to check what properties you can initialize. Lines 23 and 28 of your class are correct (delete hashmap initialization in 15 and uncomment 23 to run fine).
Regards,
Antonio.
from jaxb-ri.
Related Issues (20)
- Issues due to #1734 #1746 HOT 1
- txw runtime and compiler should have different module names
- Move JavaCompiler, Reference and J2SJAXBModel from XJC API to JXC API
- Remove JavaCompiler, Reference and J2SJAXBModel from XJC API
- Update ant tasks
- Allow globalBindings to set nameXmlTransform like in schemaBindings HOT 2
- [Regress] Namespace inheritance by children element
- Dependency Exclusion for stax-ex in jaxb-bom is incompatible with dependency:analyze-dep-mgt
- XJC ConstField generates empty javadoc comment blocks
- Backport of PR in v2.x
- schemaLocation="*" leads to issue in applicated binding
- Backport 1661 fix for 3.x
- Unmarshalling Issues HOT 1
- JAXB.unmarshal of string fails with data generated by JAXB.marshal
- XJC Javadoc generation : locale is ignored HOT 2
- Cause exception is lost for IllegalAnnotationsException HOT 1
- Regression in javadoc generated for list getter
- [binder] IllegalArgumentException if no local name is there for
- Shouldn't there be a comma?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jaxb-ri.