Google App Engine + XSLT

Fri, 02. Oct 2009

Categories: en development Tags: GAE Google App Engine Java Xalan XSLT

Google App Engine (java) doesn’t do XSLT transformations out of the box. Using a Transformer like

1TransformerFactory.newInstance().newTransformer(new StreamSource(...)).transform(...);

yields a

Nested in javax.servlet.ServletException: java.lang.NoClassDefFoundError: com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary is a restricted class. Please see the Google App Engine developer's guide for more details.: java.lang.NoClassDefFoundError: com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary is a restricted class. Please see the Google App Engine developer's guide for more details.

These google groups posts http://code.google.com/p/googleappengine/issues/detail?id=1452 and http://groups.google.com/group/google-appengine-java/browse_thread/thread/9c9fb88e1b175395 lead into the right direction but didn’t completely solve my problem. I added xalan.jar and serializer.jar from xalan-2.7.1 to war/WEB_INF/lib as suggested, but didn’t change the TransformerFactory setup.

This got me the WARNING log entries Failed calling setMethod method and Failed calling setIndent method.

This cyrillc blog-post lead me to removing all <xsl:output/> statements from the transformation and voilรก โ€“ the trafo ran fine!

The whole procedure in short: