org.apache.xml.dtm.DTMException: No more DTM IDs are available.
The Document Table Model (DTM) is Xalan's document model and uses the DTM IDs for representing objects. If you have big documents and heavy transformations the system can run out of DTM IDs (even if there are 2 ^ 16). Some bugs on this issue were already fixed: buglist.
But especially the version 2.2.D11 delivered with Sun's JDK 1.4 was susceptible to runing out of IDs. With more recent releases it's much more difficult to get the exception, but still possible.
First make sure that you do use the version you expect to use. You can do this simply by running a transformation using the environment check stylesheet. If in the output another version is shown as expected (especially 2.2.D11), you have a problem ;-)
It's not as easy to solve as you may think, because it's not a simple classpath issue. You must force the JVM to load your version of the classes before the JDK's one. Read more about it in the Xalan FAQ and at Sylvain's excellent explanation of the infamous EndorsedLibsProblem.
In short you have the following options:
place the xalan-xxx.jar, the xerces-xxx.jar (or xercesImpl.jar in newer releases) and the xml-apis.jar in Sun JDK's endorsed dirs: $JAVA_HOME/lib/endorsed
place these JARs in your servlet container's endorsed dirs: e.g. $TOMCAT_HOME/common/endorsed
- place the JARs in a special directory of your choice and set java.endorsed.dirs to this directory: -Djava.endorsed.dirs=/the/path/to/a/directory/of/your/choice
use the ParanoidCocoonServlet
If you use the correct Xalan version at the end, but the error still occurs, simplify and optimize your stylesheets. XPath expressions like //* or <xsl:number level="any"/> force Xalan to load/store the whole document in the memory. With big documents (in the sample 2 MB were mentioned) this can lead to the exception. In this sample <xsl:number/> could simply be replaced by <xsl:value-of select="position()"/>.
Hope this helps to avoid DTMException for you in the future