Monday, February 15, 2010

XSLT Using Xalan on Google App Engine

The online DAO generator at audao.spoledge.com is running on the Google App Engine. The DAO generator uses XSLT transformation and Xalan is used as the XSLT implementation.

When I tested it locally using the dev appserver, everything worked fine. But after I uploaded it to the real Google App Engine, then strange things started to happen - the XSL transformations were somehow cut, unfinished, simply different than I expected. When I looked into the logs, I found why:


javax.xml.transform.TransformerException: Failed calling setMethod method
at org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:907)
at org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:950)
at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1638)
...
Caused by: java.lang.IllegalAccessException: Class
com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$3
can not access a member of class org.apache.xalan.processor.ProcessorOutputElem with
modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$3.run(Method_.java:149)
at java.security.AccessController.doPrivileged(Native Method)
at
com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:147)
at
com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:120)
at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1626)
...


The problem was only with the XSL <xsl:output ...> tag. When I removed it, everything was OK. It was a surprise for me, because the reflection used for this tag is also used for other XSL tags and there were no errors there - just only with the <xsl:output...> tag.

Since I relied in Xalan (I have a bad experience using more than one implementation in one project), I had to patch it myself. The patch just calls the implementation Java method directly - without reflection. And it works now ! The patch you can find here (post 21).

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Big thx for this information!!!!

    I was driven crazy by this annoying unknown
    stderr!!!

    I got me a copy of XSLTAttributeDef from svn and added your code in there and placed the file in the right package in my web app... No more weird stderr's :)

    ReplyDelete