Thanks for your your replies guys, I’m trying to go with tmortagne’s pointer for now; I don’t really mind using internal APIs here, since I’m planning to just learn the form of the xml document and use it as a text template later, swapping out parameter values as needed. However, trying to generate the request body via this code
// JAVA START
RenameRequest request = new RenameRequest();
// RenameRequest class definition taken from here:
// Performing Asynchronous Tasks (XWiki.org)
var xwiki = new WikiReference(“xwiki”);
request.setId(UUID.randomUUID().toString());
request.setSpaceReference(new SpaceReference(“TestPage1”, xwiki));
request.setNewSpaceName(“TestPage2”);
request.setCheckRights(false);
request.setInteractive(false);
request.setUserReference(new DocumentReference(new LocalDocumentReference(“Home”, “myuser”), xwiki));
ModelFactory mf = new ModelFactory();
JobRequest rjr = mf.toRestJobRequest(request); // NullPointerException is thrown here
StringWriter writer = new StringWriter();
JAXBContext context = JAXBContext.newInstance(JobRequest.class);
Marshaller m = context.createMarshaller();
m.marshal(rjr, writer);
// JAVA END
results in
// STACK TRACE START
Exception in thread “main” java.lang.NullPointerException: Cannot invoke “org.xwiki.rest.internal.JAXBConverter.serializeAny(Object)” because “this.jaxbConverter” is null
at org.xwiki.rest.internal.ModelFactory.toRestMapEntry(ModelFactory.java:1095)
at org.xwiki.rest.internal.ModelFactory.toRestJobRequest(ModelFactory.java:1070)
at xwikitest.XwikiTest.main(XwikiTest.java:81)
// STACK TRACE END
Complete nonsense request parameters aside, this supposedly happens because I’m executing that piece of code standalone outside of a full xwiki instance, and ModelFactory.jaxbConverter isn’t properly injected (the field carries the @inject annotation). Is there a quick-and-easy way to fix this, or is there a factory of factories that I need to use instead of ModelFactory’s constructor?
Thanks,
Andreas