Search code examples
javaxmljaxbapache-felixaem

What's a good way to generate XML from vanilla Adobe CQ5?


My current implementation generates XML using JSPs, but the number of different record types I'm working with has grown and the number of JSP templates has become unwieldy to maintain.

So I coded up a solution using javax.xml.bind but quickly found that the code would compile but not run in OSGi. Long story short, there is a natively compiled dependency -- com.sun.* -- that is not included in the Felix boot classpath by default. Including this dependency is a matter of modifying sling.properties to include com.sun.* in the org.osgi.framework.bootdelegation config line. However, I'm working in a large corporate production environment so the thought of managing an extra configuration piece is not ideal.

So, the meat of my question: is there a better way to generate custom XML programmatically in Adobe CQ? Is there a different JAXB impl in the stack that I should be using, instead of javax.xml.bind? Is there another XML marshalling API that is more CQ/Felix friendly?


Solution

  • I've not got any concrete documentation on this yet, but it's possible to include com.sun.* without changing the Sling boot delegation.

    I've done it in this pom.xml for a demo project using CXF in CQ5 as an OSGi service. It's either the <dependency> or the <Import-Package> in the maven-bundle-plugin.

    The whole project is available on GitHub at https://github.com/antonyh/cq5-cxf - it builds, installs, and works without changes to boot delegation on CQ5.4 / CQ5.5.