XMLBeans, Piccolo, Struts, Disconnected Operation
Had a lot of “fun” today figuring out why my web app would not startup when my laptop was not connected to the network. I’ve known about this problem for awhile but I ignored it. Tomorrow I’m planning to demo said web app to some friends over lunch so I finally needed to fix it.
Starting from the exception stack trace, I figured out that the crash was happening while the Struts ActionServlet was using the Jakarta Digester to parse the app’s web.xml file. The specific problem was that the Digester was choking on this DOCTYPE in my web.xml file:
< !DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
>
The DOCTYPE is correct; the Servlet 2.3 spec says that every web.xml file must have it. The Jakarta Digester was crashing because it could not access the DTD file from java.sun.com without a network connection. A web search did not turn up much: the Struts mailing lists talked about this problem back in 2001 but the consensus was that it had been fixed a long time ago. A look at the source for ActionServlet showed that it sets up a custom XML EntityResolver that provides a local version for the DTD in question, so the bug should not have been happening.
Down the stack we go: ActionServlet is calling Jakarta Digester which is calling the Piccolo XML Parser. This is odd because Piccolo is not the parser of choice in the Jakarta world; you would normally see Xerces or Crimson. It turns out that my web app is getting Piccolo from the XMLBeans jar (xbean.jar) that is in my WEB-INF/lib directory. The Piccolo change logs say that EntityResolver handling was fixed about a year ago but the list of open bugs at http://piccolo.sourceforge.net suggests that there are still problems here. My web app is using Piccolo because xbean.jar is registering as a SAX parser factory in META-INF/services. I create a new version of the jar by unpacking it, deleting META-INF/services (but leaving all the Piccolo class files), and repacking. Bingo. Everything works. Hooray.
My xbean.jar is the original distribution from BEA. XMLBeans has had a lot of work since moving to Jakarta and they have hopefully fixed the problem by fixing or removing Piccolo. Someday I’ll upgrade and find out.
March 30th, 2004 at 8:25 am
Thanks a lot! Your posting saved me a lot of time:-)