This problem has been driving me mad. I'm trying to use Java in ColdFusion to create a Document object. When I do this:
nd = createObject("java","javax.xml.parsers.DocumentBuilder");
I can dump nd and see that it correctly loaded all the methods:
object of javax.xml.parsers.DocumentBuilder Class Name javax.xml.parsers.DocumentBuilder
Method / Return Type
getDOMImplementation() / org.w3c.dom.DOMImplementation
getSchema() / javax.xml.validation.Schema
isNamespaceAware() / boolean
isValidating() / boolean
isXIncludeAware() / boolean
newDocument() / org.w3c.dom.Document
parse(java.io.File) / org.w3c.dom.Document
parse(java.lang.String) / org.w3c.dom.Document
parse(org.xml.sax.InputSource) / org.w3c.dom.Document
parse(java.io.InputStream, java.lang.String) / org.w3c.dom.Document
parse(java.io.InputStream) / org.w3c.dom.Document
reset() / void
setEntityResolver(org.xml.sax.EntityResolver) / void
setErrorHandler(org.xml.sax.ErrorHandler) / void
I'm trying to call the newDocument() method. I've tried all the following in both cfscript and cfsets:
nd.newDocument();
nd.newDocument(JavaCast("null",""));
nd = createObject("java","javax.xml.parsers.DocumentBuilder").newDocument();
nd = createObject("java","javax.xml.parsers.DocumentBuilder").newDocument(JavaCast("null",""));
But, no matter what approach I try, I get this error:
Either there are no methods with the specified method name and argument types or the isNamespaceAware method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the > provided arguments. If this is a Java object and you verified that the method > exists, use the javacast function to reduce ambiguity.
I can see that the method was loaded.. The method isn't overloaded.. It doesn't require any arguments.. And, even when I explicitly tell CF I'm passing in null, it can't find the method..
I tried accessing the other methods in the class - and it couldn't find those either.. I'm not sure why I can dump the contents of the class - and I can see all the methods.. But, somehow CF is getting confused and can't find them when I try to call them..
Any ideas would be super helpful..
Thanks!!