Problem using Java extensions 2003-02-26 - By mkwan@(protected)
Hi, Karen
This is not related to bug 14236. I just looked at the source code. I will doubt that this problem is still reproducible with Xalan 2.4.1. In 2.4.1, the keys for the cached methods are calculated in a more sophisticated way. It is unlikely for two methods to have the same key. If you can still reproduce the problem with Xalan 2.4.1, please open a bug in the Bugzilla database.
Regards,
Morris Kwan XSLT Development IBM Toronto Lab Tel: (905)413-3729 Email: mkwan@(protected)
Karen Alexander <Karen.Alexander@(protected) To: "'xalan-dev@(protected) .apache.org'" <xalan-dev@(protected)>, mentum.com> "'xalan-j-users@(protected) .org'" <xalan-j-users@(protected)> cc: 02/26/2003 03:17 AM Subject: 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@(protected)', 'Object@(protected)', 'ExpressionContext@(protected)') >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('setErrorTag', 'Vector@(protected)', 'Object@(protected)', 'ExpressionContext@(protected)') >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache ('Object@(protected)', 'Object@(protected)', 'Object[]@(protected)') << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache --> null >> org.apache.xalan.extensions.MethodResolver:getMethod ('Class@(protected)', 'setErrorTag', 'Object[]@(protected)', 'Object[][]@(protected)', 'ExpressionContext@(protected)', '2') >> org.apache.xalan.extensions.MethodResolver:scoreMatch ('Class[] @(protected)', '0', 'Object[]@(protected)', '1000') << org.apache.xalan.extensions.MethodResolver:scoreMatch --> "1000" >> org.apache.xalan.extensions.MethodResolver:convertParams ('Object []@(protected)', 'Object[][]@(protected)', 'Class[]@(protected)', 'ExpressionContext@(protected)') >> org.apache.xalan.extensions.MethodResolver:convert ( 'Object@(protected)', 'Class@(protected)') << 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@(protected)', 'Object@(protected)', 'Object[]@(protected)', 'Object@(protected)') 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@(protected)', 'Object@(protected)', 'ExpressionContext@(protected)') >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('execute', 'Vector@(protected)', 'Object@(protected)', 'ExpressionContext@(protected)') >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache ('Object@(protected)', 'Object@(protected)', 'Object[]@(protected)') << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache --> "public void com.documentum.xml.xdql.DfXmlQuery.setErrorTag(java.lang.String)" >> org.apache.xalan.extensions.MethodResolver:convertParams ('Object[] @(protected)', 'Object[][]@(protected)', 'Class[]@(protected)', 'ExpressionContext@(protected)')
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) 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
|
|