Tapestry 5.1 Woodstox

In my last post I suspected the Woodstox lib to be the reason that Tapestry 5.1 does not work on Google App Engine (GAE).

So, I tried to eliminate the Woodstox lib and just use Stax – and it turned out to be really easy. The only problem was that the standard Stax parser does not handle DTDs in a nice way – you have to parse them yourself.

Changes to Tapestry:

  • use XMLInputFactory instead of XMLInputFactory2 in TemplateParserImpl
  • remove inputFactory.configureForSpeed(); in TemplateParserImpl
  • use XMLStreamReader instead of XMLStreamReader2 in StaxTemplateParser
  • change the dtd() method StaxTemplateParser to (this could be nicer):
    private void dtd() throws XMLStreamException
        String dtd = reader.getText();
        String[] dtdElements = dtd.split(" ");
        if(dtdElements.length > 3)
            String rootName = dtdElements[1];
            String publicId = null;
            String systemId = null;
                publicId = dtdElements[3];
                if(dtdElements.length > 4)
                    systemId = dtdElements[4];
            else if("SYSTEM".equals(dtdElements[2]))
                systemId = dtdElements[3];
            tokenAccumulator.add(new DTDToken(rootName, publicId, systemId, getLocation()));

I have eliminated Woodstox – Tapestry runs now on plain Stax (included in JRE). But it still does not work on GAE – seems that the whole Stax package is locked and cannot be used. Maybe I give it another try. Hmmm.


Tapestry in the Cloud

I just got an Goole AppEngine account. The first thing I had to try was if Tapestry 5 works – and yes it does.

Then I tried a simple Tapestry 5.1 application (actually the same app with the newer library version and it does not work. What I got was this:

java.lang.RuntimeException: Exception constructing service 'TemplateParser':
Error invoking constructor org.apache.tapestry5.internal.services.TemplateParserImpl(Map, boolean) (at TemplateParserImpl.java:50)
via org.apache.tapestry5.internal.services.InternalModule.bind(ServiceBinder) (at InternalModule.java:65) (for service 'TemplateParser'):
Could not initialize class com.google.apphosting.runtime.security.shared.stub.javax.xml.stream.XMLInputFactory

It seems that the Woodstox StAX2 lib is the problem.