Problem using Java extensions 2003-02-26 - By Karen Alexander
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)' <mailto:'Vector@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'ExpressionContext@(protected)' <mailto:'ExpressionContext@(protected)'> ) >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('setErrorTag', 'Vector@(protected)' <mailto:'Vector@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'ExpressionContext@(protected)' <mailto:'ExpressionContext@(protected)'> ) >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache ('Object@(protected)' <mailto:'Object@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'Object[]@(protected)') << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache --> null >> org.apache.xalan.extensions.MethodResolver:getMethod ('Class@(protected)' <mailto:'Class@(protected)'> , 'setErrorTag', 'Object[]@(protected)', 'Object[][]@(protected)', 'ExpressionContext@(protected)' <mailto:'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)' <mailto:'ExpressionContext@(protected)'> ) >> org.apache.xalan.extensions.MethodResolver:convert ('Object@(protected)' <mailto:'Object@(protected)'> , 'Class@(protected)' <mailto:'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)' <mailto:'Object@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'Object[]@(protected)', 'Object@(protected)' <mailto:'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)' <mailto:'Vector@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'ExpressionContext@(protected)' <mailto:'ExpressionContext@(protected)'> ) >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('execute', 'Vector@(protected)' <mailto:'Vector@(protected)'> , 'Object@(protected)' <mailto:'Object@(protected)'> , 'ExpressionContext@(protected)' <mailto:'ExpressionContext@(protected)'> ) >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache ('Object@(protected)' <mailto:'Object@(protected)'> , 'Object@(protected)' <mailto:'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)' <mailto:'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 <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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <TITLE>Message</TITLE>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD> <BODY> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>I have a Java class that my customers can call from within their stylesheets. However, </FONT></SPAN><SPAN class=000024406-26022003><FONT face="Comic Sans MS " size=2>I'm experiencing a problem where, occasionally, the Java extension calls are calling the wrong methods in my class.</FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2></FONT></SPAN> </DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>Here's an excerpt from a stylesheet that is making Java extension calls to my class (DfXmlQuery):</FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2><FONT face="Courier New"><xsl:variable name="xdql" select="java:com.documentum.xml.xdql.DfXmlQuery.new()"/><BR><xsl:variable name="init" select="java:init($xdql)"/><BR><xsl:variable name="param" select="java:setDql($xdql,$dql)"/><BR><xsl:variable name="param3" select="java:includeContent($xdql,true())"/><BR><xsl:variable name="param4" select="java:setErrorTag($xdql,$errorTag)"/><BR></FONT><FONT face="Courier New"><xsl:variable name="execute" select="java:execute($xdql,'DF_READ_QUERY',$DMS_SESSION_ID)"/><BR></FONT>< /FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>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).</FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2></FONT></SPAN> </DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>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. </FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2></FONT></SPAN> </DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>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').</FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2></FONT></SPAN> </DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2>Here is a snippet from my trace output where the method is not (yet) in the cache:</FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2><FONT face="Courier New" size=1>>> org.apache.xalan.extensions.ExtensionsTable:extFunction ('http://xml.apache.org/xslt/java', 'setErrorTag', <A href="mailto:'Vector@(protected)'">'Vector@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR> >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('setErrorTag', <A href="mailto:'Vector@(protected)'">'Vector@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR> >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache (<A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, 'Object[]@(protected)')<BR> << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache --> null<BR> >> org.apache.xalan.extensions.MethodResolver:getMethod (<A href="mailto:'Class@(protected)'">'Class@(protected)'</A>, 'setErrorTag', 'Object[]@(protected)', 'Object[][]@(protected)', <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>, '2')<BR> >> org.apache.xalan.extensions.MethodResolver:scoreMatch ('Class[]@(protected)', '0', 'Object[]@(protected)', '1000')<BR> << org.apache.xalan.extensions.MethodResolver:scoreMatch --> "1000"<BR> >> org.apache.xalan.extensions.MethodResolver:convertParams ('Object[]@(protected)', 'Object[][]@(protected)', 'Class[]@(protected)', <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR> >> org.apache.xalan.extensions.MethodResolver:convert (<A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'Class@(protected)'">'Class@(protected)'</A>)<BR> << org.apache.xalan.extensions.MethodResolver:convert --> "XDQLError"<BR> << org.apache.xalan.extensions.MethodResolver:getMethod --> "public void com.documentum.xml.xdql.DfXmlQuery.setErrorTag(java.lang.String)"<BR> >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:putToCache (<A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, 'Object[]@(protected)', <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>)<BR>putToCache-> ;methodKey=617111046198565750<BR> << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:putToCache --> null<BR> >> com.documentum.xml.xdql.DfXmlQuery:setErrorTag ('XDQLError')<BR> << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction --> null<BR><< org.apache.xalan.extensions.ExtensionsTable:extFunction --> null</FONT></FONT></SPAN></DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2></FONT></SPAN> </DIV> <DIV><SPAN class=000024406-26022003><FONT face="Comic Sans MS" size=2><FONT face="Courier New" size=1><FONT face="Comic Sans MS" size=2></FONT> </DIV> <DIV><SPAN class=000024406-26022003></SPAN><FONT face="Comic Sans MS"><FONT size=2>I<SPAN class=000024406-26022003>n this snippet, the cache lookup for the 'execute' method returns 'setErrorTag':</SPAN></FONT></FONT><BR>>> org.apache.xalan.extensions.ExtensionsTable:extFunction ('http://xml.apache.org/xslt/java', 'execute', <A href="mailto:'Vector@(protected)'">'Vector@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR> >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:callFunction ('execute', <A href="mailto:'Vector@(protected)'">'Vector@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR> >> org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache (<A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, <A href="mailto:'Object@(protected)'">'Object@(protected)'</A>, 'Object[]@(protected)')<BR> << org.apache.xalan.extensions.ExtensionHandlerJavaPackage:getFromCache --> "public void com.documentum.xml.xdql.DfXmlQuery.setErrorTag(java.lang.String)"<BR> >> org.apache.xalan.extensions.MethodResolver:convertParams ('Object[]@(protected)', 'Object[][]@(protected)', 'Class[]@(protected)', <A href="mailto:'ExpressionContext@(protected)'">'ExpressionContext@(protected)'</A>)<BR></DIV>< /FONT><FONT face="Courier New" size=1></FONT> <DIV> </DIV> <DIV><SPAN class=000024406-26022003>My customers are using Xalan 2.2.0, but I 've had them try 2.4.1 and them still see the problem. </SPAN></DIV> <DIV><SPAN class=000024406-26022003></SPAN> </DIV> <DIV><SPAN class=000024406-26022003>I've been searching through the bug database and bug 14236 (<A href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14236">http://nagoya .apache.org/bugzilla/show_bug.cgi?id=14236</A>) looks somewhat similar to my issue. Can you tell me if the fix is in the 2.4.1 release? </SPAN></DIV> <DIV><SPAN class=000024406-26022003></SPAN> </DIV> <DIV><SPAN class=000024406-26022003></SPAN><SPAN class=000024406-26022003>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?</SPAN></DIV></FONT></SPAN> <DIV><FONT face="Comic Sans MS" size=2></FONT> </DIV> <DIV><FONT face="Comic Sans MS" size=2><SPAN class=000024406-26022003>Thanks for your help,</SPAN></FONT></DIV> <DIV><FONT face="Comic Sans MS" size=2><SPAN class=000024406-26022003></SPAN></FONT><FONT face="Comic Sans MS" size=2> - Karen</FONT> </DIV> <DIV> </DIV></BODY></HTML>
|
|