Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change 
notification.

The following page has been changed by JoergHeinicke:
http://wiki.apache.org/cocoon/NoMoreDtmIdError

------------------------------------------------------------------------------
  
  ==  The reason ==
  The Document Table Model ([http://xml.apache.org/xalan-j/dtm.html 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: 
[http://nagoya.apache.org/bugzilla/buglist.cgi?product=XalanJ2&short_desc=DTM+available&short_desc_type=allwordssubstr&order=Bug+Number
 buglist].[[BR]]
- 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 possible: 
[http://marc.theaimsgroup.com/?t=105355207600005&r=1&w=2].
+ 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 
[http://marc.theaimsgroup.com/?t=105355207600005&r=1&w=2 possible].
  
  ==  The solution ==
  First make sure that you '''do''' use the version you expect to use. You can 
do this simply by running a transformation using the 
[http://xml.apache.org/xalan-j/faq.html#environmentcheck environment check 
stylesheet]. If in the output another version is shown as expected (especially 
2.2.D11), you have a problem ;-)[[BR]]
@@ -13, +13 @@

  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 
[http://xml.apache.org/xalan-j/faq.html#jdk14 FAQ] and at Sylvain's excellent 
explanation of the ''infamous EndorsedLibsProblem''.[[BR]]
  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 
[http://java.sun.com/j2se/1.4.1/docs/guide/standards/ 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 (see 
[http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=104307686731753&w=2])
+  *  place these JARs in your servlet container's endorsed dirs: e.g. 
[http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=104307686731753&w=4 
$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
  [[BR]]
- If you have at the end the correct Xalan version in use, 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 
[http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=105355235413182&w=2 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()"/>}}}.
+ 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 
[http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=105355235413182&w=4 sample] 
2 MB were mentioned) this can lead to the exception. In this sample 
{{{<xsl:number/>}}} could simply be 
[http://marc.info/?t=105359584000003&r=1&w=4 replaced] by {{{<xsl:value-of 
select="position()"/>}}}.
  
  Hope this helps to avoid DTMException for you in the future :-)