I'm hoping there is another design idea I can use for this problem. I have to implement xpath functions that map to various xforms functions for our users. My solution was to use java extension functions and do some mapping between my own java namespace and what the users see (i.e. the users see xforms functions but I map these before evaluation to my own java namespace).

The main problem is that I cannot change the function signature. This means I cannot use java extension functions that access instance methods (which require an extra parameter) and I have to use an awful hack that uses static methods. Basically I store an instance of my value resolver in a synchronized static field and map static java extension functions to this object. Ugly, but at least it worked until now.

Now I find this is failing when I try to run the app in Amazon's cloud environment. Somewhere inside jaxp classes as called by saxon (com.sun.org.apache.xpath.internal.functions.FuncExtFunction.execute(FuncExtFunction.java:206)) I'm getting a NullPointerException. Just to be clear, this app runs fine outside of the virtualized Amazon environment. I suspect the root cause is how jaxp classes are being loaded because I've seen that happen with jaxp in other VPS enviornments.

Whatever the cause, I'm hoping that if I redesign this hack I can clean up my code and hopefully make this bug disappear.

Is there another design alternative to implementing xforms (or similar) functions in xpath? I'm ok using s9 exclusively if that will help - jaxp causes me nothing but trouble so I'm ready to toss it out the window anyway. The function signatures (now(), index(), instance(), etc.) cannot be changed, require object instances to resolve, and I need to evaluate them within xpath alone (i.e. not within xslt or xquery).

I hope there is an answer because it looks like we can't host our application in Amazon if this doesn't get resolved.