You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Karen Alexander <Ka...@documentum.com> on 2003/02/26 09:17:44 UTC

Problem using Java extensions

I have a Java class that my customers can call from within their
stylesheets.  However, I'm experiencing a problem where, occasionally, the
Java extension calls are calling the wrong methods in my class.
 
Here's an excerpt from a stylesheet that is making Java extension calls to
my class (DfXmlQuery):
<xsl:variable name="xdql"
select="java:com.documentum.xml.xdql.DfXmlQuery.new()"/>
<xsl:variable name="init" select="java:init($xdql)"/>
<xsl:variable name="param" select="java:setDql($xdql,$dql)"/>
<xsl:variable name="param3" select="java:includeContent($xdql,true())"/>
<xsl:variable name="param4" select="java:setErrorTag($xdql,$errorTag)"/>
<xsl:variable name="execute"
select="java:execute($xdql,'DF_READ_QUERY',$DMS_SESSION_ID)"/>

The template is instantiating my object and calling a number of methods on
it.  However, occasionally the wrong method will be called.  For example,
instead of the calling the 'execute' method, I will sometimes see that the
'setErrorTag' method is called (with the parameters that were given to the
'execute' method).
 
I have placed some tracing code into the org.apache.xalan.extensions package
to trace how the extension functions are being cached.  The problem seems to
be related to having the wrong function returned from a cache.  
 
In the trace output, it looks like we do a lookup to see if the method has
been cached.  If not, it is added to the cache.  However, at one point we do
a lookup for a method (e.g. 'execute') and the cache returns a different
method (e.g. 'setErrorTag').
 
Here is a snippet from my trace output where the method is not (yet) in the
cache:
>> org.apache.xalan.extensions.ExtensionsTable:extFunction
('http://xml.apache.org/xslt/java', 'setErrorTag', 'Vector@594'
<mailto:'Vector@594'> , 'Object@8e01cd9a' <mailto:'Object@8e01cd9a'> ,
'ExpressionContext@5eb' <mailto:'ExpressionContext@5eb'> )
  >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction
('setErrorTag', 'Vector@594' <mailto:'Vector@594'> , 'Object@8e01cd9a'
<mailto:'Object@8e01cd9a'> , 'ExpressionContext@5eb'
<mailto:'ExpressionContext@5eb'> )
    >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache
('Object@8e01cd9a' <mailto:'Object@8e01cd9a'> , 'Object@53d'
<mailto:'Object@53d'> , 'Object[]@554')
    << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache
--> null
    >> org.apache.xalan.extensions.MethodResolver:getMethod ('Class@392'
<mailto:'Class@392'> , 'setErrorTag', 'Object[]@554', 'Object[][]@53b',
'ExpressionContext@5eb' <mailto:'ExpressionContext@5eb'> , '2')
      >> org.apache.xalan.extensions.MethodResolver:scoreMatch
('Class[]@52f', '0', 'Object[]@554', '1000')
      << org.apache.xalan.extensions.MethodResolver:scoreMatch --> "1000"
      >> org.apache.xalan.extensions.MethodResolver:convertParams
('Object[]@554', 'Object[][]@53b', 'Class[]@52f', 'ExpressionContext@5eb'
<mailto:'ExpressionContext@5eb'> )
        >> org.apache.xalan.extensions.MethodResolver:convert
('Object@2f47931f' <mailto:'Object@2f47931f'> , 'Class@431'
<mailto:'Class@431'> )
        << org.apache.xalan.extensions.MethodResolver:convert -->
"XDQLError"
    << org.apache.xalan.extensions.MethodResolver:getMethod --> "public void
com.documentum.xml.xdql.DfXmlQuery.setErrorTag(java.lang.String)"
    >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:putToCache
('Object@8e01cd9a' <mailto:'Object@8e01cd9a'> , 'Object@53d'
<mailto:'Object@53d'> , 'Object[]@554', 'Object@69dfeb2c'
<mailto:'Object@69dfeb2c'> )
putToCache->methodKey=617111046198565750
    << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:putToCache
--> null
    >> com.documentum.xml.xdql.DfXmlQuery:setErrorTag ('XDQLError')
  << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction
--> null
<< org.apache.xalan.extensions.ExtensionsTable:extFunction --> null
 
 
In this snippet, the cache lookup for the 'execute' method returns
'setErrorTag':
>> org.apache.xalan.extensions.ExtensionsTable:extFunction
('http://xml.apache.org/xslt/java', 'execute', 'Vector@af'
<mailto:'Vector@af'> , 'Object@8e01cd9a' <mailto:'Object@8e01cd9a'> ,
'ExpressionContext@5eb' <mailto:'ExpressionContext@5eb'> )
  >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction
('execute', 'Vector@af' <mailto:'Vector@af'> , 'Object@8e01cd9a'
<mailto:'Object@8e01cd9a'> , 'ExpressionContext@5eb'
<mailto:'ExpressionContext@5eb'> )
    >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache
('Object@8e01cd9a' <mailto:'Object@8e01cd9a'> , 'Object@53d'
<mailto:'Object@53d'> , 'Object[]@9f')
    << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache
--> "public void
com.documentum.xml.xdql.DfXmlQuery.setErrorTag(java.lang.String)"
    >> org.apache.xalan.extensions.MethodResolver:convertParams
('Object[]@9f', 'Object[][]@85', 'Class[]@83', 'ExpressionContext@5eb'
<mailto:'ExpressionContext@5eb'> )

 
My customers are using Xalan 2.2.0, but I've had them try 2.4.1 and them
still see the problem. 
 
I've been searching through the bug database and bug 14236
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14236
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14236> ) looks somewhat
similar to my issue.  Can you tell me if the fix is in the 2.4.1 release?  
 
I'm guessing that the fix isn't in 2.4.1, so I'm trying to build the code
from CVS.  However, I'm having some problems because I have to make sure
that the code is compatible with Java 1.1.8.  Are the jar files available
for the nightly builds?
 
Thanks for your help,
 - Karen