2

I have the following XSL which defines a namespace for my Java Class. In a nutshell I'm trying to point to a different resource bundle depending upon a value in my XML file (I know Resource Bundles are really for internationalization but why re-create the wheel?):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:java="http://xml.apache.org/xalan/java"
                xmlns:pf="my.package.common.PropertiesFinder">

    <xsl:variable name="compType" select="//comp_type"/>
    <xsl:variable name="props" select="pf:getPropsFile($compType)"/>
    <xsl:variable name="DEF6Resources" select="java:util.ResourceBundle.getBundle($props)"/>

When the transform runs I get the following error:

java.lang.NoSuchMethodException: For extension function, could not find method org.apache.xml.utils.NodeVector.getProps([ExpressionContext,])

Can anyone shed any light on why this is happening please. It's clearly something to do with my classpath/loader but I'm not sure what to do...

Many thanks in advance.

Anna

2
  • I'm not sure why you have a "classnotfoundexception" tag, but the body contains NoSuchMethodException instead. Commented Oct 26, 2010 at 11:01
  • Where is the jar file that contains org.apache.xml.utils.NodeVector.getProps()? What is the current classpath as far as you know? How are you passing the classpath to the XSLT processor (which I assume is Xalan)? I'm shooting in the dark, but presumably the answers to those q's will help us and you narrow down the problem. Commented Oct 26, 2010 at 11:19

2 Answers 2

1

You have to check your namespace definition.

xmlns:pf="my.package.common.PropertiesFinder"

When you are defining a namespace for a Java class, you have to prepend it with the java: prefix.

xmlns:pf="java:my.package.common.PropertiesFinder"

Also, the method invoked (getPropsFile) must be declared as static.

And, I think that at this block of code:

<xsl:variable name="DEF6Resources" select="java:util.ResourceBundle.getBundle($props)"/>

You are missing the java root package:

<xsl:variable name="DEF6Resources" select="java:java.util.ResourceBundle.getBundle($props)"/>

(I'm not sure of this last, maybe the Xalan parser prepends it for some cases?)

Sign up to request clarification or add additional context in comments.

Comments

0

Got same problem.

Finally I found that Xalan is unable to load classes with static blocks or static variables, or something like that. Maybe PropertiesFinder or ResourceBundle use static blocks internally. The error message was really misleading...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.